Esempio n. 1
0
        static void Main()
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            foreach (var item in synth.GetInstalledVoices()) // zeigt die namen aller installierten stimmen an
            {
                Console.WriteLine(item.VoiceInfo.Name);
            }

            synth.SelectVoice("Microsoft Hedda Desktop");
            synth.Speak("Hallo Welt");
            Console.ReadLine();
        }
Esempio n. 2
0
        public static void SpeakSsml(string ssml, string defaultVoiceName, MemoryStream memoryStream, SpeechSynthesizer speechSynthesizer = null)
        {
            speechSynthesizer = speechSynthesizer ?? SpeechSynthesizer;
            lock (speechSynthesizer)
            {
                if (!string.IsNullOrEmpty(defaultVoiceName))
                {
                    speechSynthesizer.SelectVoice(defaultVoiceName);
                }

                SpeechSynthesizer.SetOutputToAudioStream(memoryStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, SPEECH_SAMPLE_RATE, SPEECH_BITS_PER_SAMPLE, SPEECH_CHANNELS, SPEECH_SAMPLE_RATE * SPEECH_CHANNELS * SPEECH_BITS_PER_SAMPLE / 8, 2, null));
                //speechSynthesizer.SetOutputToWaveStream(memoryStream);

                speechSynthesizer.SpeakSsml(ssml);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// SAPI5を起動する
 /// </summary>
 public void Activate()
 {
     if (!IsActive())
     {
         synthesizer = new SpeechSynthesizer();
         var voice = synthesizer.GetInstalledVoices();
         for (int i = 0; i < voice.Count; i++)
         {
             var v = voice[i].VoiceInfo.Name;
             if (v.IndexOf(_voiceName) >= 0)
             {
                 synthesizer.SelectVoice(v);
                 break;
             }
         }
     }
 }
Esempio n. 4
0
        static string VoiceChooser(SpeechSynthesizer synthesizer)
        {
            string voicename;
            var    culture = CultureInfo.GetCultureInfo("zh-TW");
            var    voices  = synthesizer.GetInstalledVoices(culture);

            if (voices.Count > 0)
            {
                voicename = voices[0].VoiceInfo.Name;
                synthesizer.SelectVoice(voicename);
                Console.WriteLine("找到中文語音合成引擎 : " + voicename);
            }
            else
            {
                voicename = synthesizer.GetInstalledVoices()[0].VoiceInfo.Name;
                Console.WriteLine("沒有中文語音合成引擎,使用英文語音合成引擎 : " + voicename);
            }
            return(voicename);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();

            var voices = synth.GetInstalledVoices(CultureInfo.GetCultureInfo("ES-es"));

            synth.SelectVoice(synth.GetInstalledVoices().Single(x => x.VoiceInfo.Name.Contains("Helena")).VoiceInfo.Name); //Raul/Laura/Helena

            // Configure the audio output.
            synth.SetOutputToDefaultAudioDevice();

            // Speak a string.
            //synth.Speak("Hola Anabel");
            //Console.ReadKey();
            //synth.Speak("¿Como estas?");
            //Console.ReadKey();
            //synth.Speak("¿Como se llama tu perrito?");
            //Console.ReadKey();
            //synth.Speak("¿Como se llama tu cole?");
            //Console.ReadKey();

            synth.Speak("Hola Chombita.");
            Console.ReadKey();
            synth.Speak("Tienes que irte a la cama ya");
            Console.ReadKey();
            synth.Speak("¿Te veo mañana?");
            Console.ReadKey();
            synth.Speak("Ve con mama, y hazle caso en todo.");
            Console.ReadKey();


            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }