2015-11-23 64 views
0

我有以下程序:語音合成,無法選擇安裝語音

 SpeechSynthesizer synth = new SpeechSynthesizer(); 
     List<InstalledVoice> installedVoices = new List<InstalledVoice>(); 
     foreach (InstalledVoice voice in synth.GetInstalledVoices()) 
     { 
      installedVoices.Add(voice); 
      Console.WriteLine(voice.VoiceInfo.Name); 
     } 
     synth.SelectVoice(installedVoices[1].VoiceInfo.Name); 
     synth.Speak("This is in English"); 

安裝的聲音的輸出是這樣的:

Microsoft Anna 
Microsoft Server Speech Text to Speech Voice (en-GB, Hazel) 
Microsoft Server Speech Text to Speech Voice (fr-CA, Harmonie) 
Microsoft Server Speech Text to Speech Voice (nl-NL, Hanna) 

當我運行synth.SelectVoice(installedVoices[0].VoiceInfo.Name); 程序它工作沒有任何問題。 當synth.SelectVoice(installedVoices[1].VoiceInfo.Name); 運行它得到淡褐色讀一句,我得到以下SystemArgumentException

{"Cannot set voice. No matching voice is installed or the voice was disabled."} 

而且所有的聲音都啓用。 我已經安裝了以下幾件事:

  1. 微軟語音平臺 - 運行時(第11版)
  2. 微軟語音平臺 - 軟件開發工具包(SDK)(第11版)
  3. 而其他語言所看到的打印清單。

而且我也跟着this指導讓我的語言我的OS(win7x64)的認可。 我怎麼只能使用安娜?

回答

3

我使它工作。這就是我所做的。 我用錯了SpeechSynthesizer我用System.Speech.SpeechSynthesizer 而不是Microsoft.Speech.Synthesis。你必須添加Speech.dll參考這是C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly

然後我可以使用淡褐色,和諧和漢娜,但安娜不再(我不需要她反正)。

另外,不要忘了將項目構建設置爲x64,因爲SDK是x64或安裝x86 SDK和運行時。