Exemple #1
0
        public static async Task Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;

            // credentials
            var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            var keyFile     = Path.Combine(userProfile, "Projects", "DevKeys", "azure-speech.txt");
            var lines       = File.ReadAllLines(keyFile);

            client = new TextToSpeechStreamClient(
                lines[1],
                lines[0],
                lines[2],
                new JsonFactory <Voice[]>(),
                AudioFormat.Raw24KHz16BitMonoPCM,
                new CachingStrategy
            {
                new FileCacheLayer(new DirectoryInfo(Path.Combine(userProfile, "Projects")))
            });

            using var p = player = new SoundPlayer();
            using var f = form = new SpeechGen();
            form.SetVoices(await client.GetVoicesAsync()
                           .ConfigureAwait(true));

            form.GenerateSpeech += Form_GenerateSpeech;

            Application.Run(form);
        }
Exemple #2
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;

            // credentials
            var userProfile = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
            var projectsDir = userProfile.CD("Projects");
            var keyFile     = projectsDir.CD("DevKeys").Touch("azure-speech.txt");
            var lines       = File.ReadAllLines(keyFile.FullName);

            client = new TextToSpeechClient(
                lines[0],
                lines[1],
                lines[2],
                new JsonFactory <Voice[]>(),
                new NAudioAudioDataDecoder(),
                new CachingStrategy
            {
                new FileCacheLayer(projectsDir)
            });

            using var p = player = new SoundPlayer();
            using var f = form = new SpeechGen();
            form.SetVoices(client.GetVoicesAsync().Result);

            form.GenerateSpeech += Form_GenerateSpeech;

            Application.Run(form);
        }