语音合成器“输入字符串不是正确的格式” [英] Speech Synthesizer "Input string was not in a correct format"

查看:638
本文介绍了语音合成器“输入字符串不是正确的格式”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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

我无法为我的生活找出导致这个错误的原因:

I can not for the life of me figure out what exactly is causing this error:

输入字符串格式不正确。

"Input string was not in a correct format."

引起此错误的行是当我调用 _synth.Speak(_prompt);
\\
编辑:我已经尝试这个代码在我的台式机上,它的工作正常,安装在我的笔记本电脑上。仍然我不太确定如何解决此问题。

The line that causes this error is when I call _synth.Speak(_prompt);
I have tried this code on my desktop computer and it works fine so something is wrong with my install on my laptop. Still I'm not too sure how to fix this...

编辑:

堆栈跟踪:

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


推荐答案

您的机器的注册表被打乱了,它包含无效的语音配置数据。相关键是 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens 。在下面,你会发现安装的声音。英语机器通常有MS-Anna,但如果你购买了更多的机器,可能还有其他机器。

The registry of your machine is messed up, it contains invalid voice configuration data. The relevant key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens. Underneath, you'll find the installed voices. An English machine typically has MS-Anna there but there can be others if you purchased more.

错误的值是Attribute\Language,它不是十六进制数字应该是。像409,英语的LCID的十六进制值。

The messed up value is Attribute\Language, it isn't an hexadecimal number like it should be. Like "409", the hex value of the LCID for English.

您可以通过卸载您添加的语音,删除注册表中的坏语音或修复语言值中。重新安装是棘手的,这是Vista上的Windows设置的一部分。如果你不能得到它固定,你需要从superuser.com的帮助。或您的设置DVD。

You might fix it by uninstalling voices you added, deleting bad voices in the registry or fixing the Language value. Reinstalling is tricky, this is part of the Windows setup on Vista and up. You'll need help from superuser.com if you can't get it fixed. Or your setup DVD.

这篇关于语音合成器“输入字符串不是正确的格式”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆