c# - 语音合成器 "Input string was not in a correct format"

标签 c# text-to-speech speech-synthesis

这是我的代码:

string _message = "Hello world.";
SpeechSynthesizer _synth = new SpeechSynthesizer();
Prompt _prompt = new Prompt(_message);
_synth.Speak(_prompt);

我这辈子都弄不清楚到底是什么导致了这个错误:

“输入的字符串格式不正确。”

导致此错误的行是当我调用 _synth.Speak(_prompt);
编辑:我在我的台式电脑上试过这段代码,它工作正常,所以我在我的笔记本电脑上安装有问题。我仍然不太确定如何解决这个问题...

编辑:

堆栈跟踪:

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

最佳答案

我决定进入语音 key 寄存器,在备份该 key 后,我删除了一个接一个的所有语音,每次都尝试输入代码,直到错误消失。错误是 Loquendo 的声音。 在那之后,我尝试恢复备份(所有声音)再次寻找错误并且......操作系统回答说无法写入一个值,因为它正在被另一个应用程序使用......这就是神奇的事情:一切正常!

关于c# - 语音合成器 "Input string was not in a correct format",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10304913/

相关文章:

c# - 如何在SilverLight中添加IFRAME?

c# - 如何在 Unity3D 的 OnDrawGizmos 中以屏幕像素坐标绘制某些内容?

html - 是否可以使用 Web Speech API 突出显示 <strong> 在句子中说出的每个单词

javascript - 言语合成事件的问题

vb.net - 创建每个样本值具有任意位的WAV文件?

android - TextToSpeech 在 Android 中使用 synthesizeToFile 需要太多时间

c# - Asp.net MVC 使用 JQuery 填充列表框?

c# - 无法使用 C# TCP 服务器和 C++ TCP 客户端接收消息

python - pyttsx 引擎 runAndWait 在 Yosemite 上不返回的解决方法

ios - 在后台的预定点播放文本到语音