using System; using System.Speech.Synthesis; namespace testvoice { class Program { static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); //獲取本機上所安裝的所有的Voice的名稱 string voicestring = ""; foreach (InstalledVoice iv in synth.GetInstalledVoices()) { voicestring += iv.VoiceInfo.Name + ","; } //voicestring的值是Microsoft Lili,Microsoft Anna synth.Volume = 100; synth.Rate = -5; //根據Voice的name屬性確定要使用的Voice //synth.SelectVoice("Microsoft Anna");//美式發音,但只能讀英文 synth.SelectVoice("Microsoft Lili");//能讀中英文 //根據文字內容合成語音 synth.Speak("你好"); Console.Read(); } } }
