这是我的代码:
string _message = "Hello world.";
SpeechSynthesizer _synth = new SpeechSynthesizer();
Prompt _prompt = new Prompt(_message);
_synth.Speak(_prompt);
我一生都无法弄清楚到底是什么导致了这个错误:
“输入字符串的格式不正确。”
导致此错误的行是当我调用_synth.Speak(_prompt);
编辑:我已经在我的台式计算机上尝试过这段代码,它工作正常,所以我在笔记本电脑上的安装出现了问题。我仍然不太确定如何解决这个问题......
EDIT:
堆栈跟踪:
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffe
r& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo in
fo)
at System.Speech.Internal.SapiAttributeParser.GetCultureInfoFromLanguageStrin
g(String valueString)
at System.Speech.Synthesis.VoiceInfo..ctor(VoiceObjectToken token)
at System.Speech.Internal.Synthesis.VoiceSynthesis.BuildInstalledVoices(Voice
Synthesis voiceSynthesizer)
at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speech
Synthesizer)
at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer()
at System.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
at TTSTesting.Program.Speak(String _message) in C:\Users\ctanaka\Desktop\TTST
esting\TTSTesting\Program.cs:line 22
我决定进入语音密钥寄存器,并在备份该密钥后,每次尝试该代码时都删除一个又一个的所有语音,直到错误消失。错误出在 Loquendo 的声音中。
之后,我尝试恢复备份(所有声音)再次查找错误,然后...操作系统回答说无法写入值,因为它正在被另一个应用程序使用...这就是神奇的事情:一切正常!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)