【发布时间】:2016-01-13 20:38:54
【问题描述】:
我正在修改Scott Hanselman 的BabySmash 代码以支持其他语言。
- 我根据these steps 安装了语音平台和新语言。
-
该语言现在显示在注册表中:
-
Windows 现在可以选择和播放语言了:
System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices()现在返回声音。- 但是下面代码中的
SelectVoice()会抛出错误“System.ArgumentException: 无法设置语音。未安装匹配的语音或语音被禁用。”
string phrase = null;
SpeechSynthesizer speech = new SpeechSynthesizer();
CultureInfo keyboardCulture = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).FirstOrDefault();
if (neededVoice == null)
{
phrase = "Unsupported Language";
}
else if (!neededVoice.Enabled)
{
phrase = "Voice Disabled";
}
else
{
speech.SelectVoice(neededVoice.VoiceInfo.Name);
}
speech.Speak(phrase);
我已经尝试升级到
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Speech.dll。-
我有 verified that the versions 和
Microsoft.Speech.dll和语言包匹配。 此代码适用于我已经安装的默认语音。
无奈之下,我什至尝试通过反射直接调用
System.Speech.Internal.Synthesis.VoiceSynthesis.GetVoice(),但同样的错误。
如果您能提供任何帮助,我将不胜感激!谢谢。
【问题讨论】:
标签: c# text-to-speech speechsynthesizer microsoft-speech-platform