c# - 使用 Microsoft.Speech SDK 的文本转语音抛出 FileNotFoundException?

标签 c# speech-synthesis

我正在使用 Microsoft.Speech SDK (11.0) 将文本转换为语音。我有一个 Windows 窗体应用程序,我正在使用非常基本的代码来读出输入的文本,但它失败了。这是我点击按钮时的代码:

SpeechSynthesizer syn = new SpeechSynthesizer();
PromptBuilder pb = new PromptBuilder();
pb.AppendText("Welcome, everyone");
syn.Speak(pb);

错误发生在上面代码的最后一行:

FileNotFoundException was unhandled
Exception from HRESULT: 0x8004503A

这是完整的堆栈跟踪:

at Microsoft.Speech.Synthesis.SpeechSynthesizer.SpeakPrompt(Prompt prompt, Boolean async)
at Microsoft.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
at Microsoft.Speech.Synthesis.SpeechSynthesizer.Speak(PromptBuilder promptBuilder)
at MSSpeechSynth.Form1.btnSpeak_Click(Object sender, EventArgs e) in      C:\Users\prashant.k\Desktop\MSSpeechSynth\MSSpeechSynth\Form1.cs:line 30
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MSSpeechSynth.Program.Main() in C:\Users\prashant.k\Desktop\MSSpeechSynth\MSSpeechSynth\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

是什么导致了这个错误?

谢谢

最佳答案

正如 Microsoft 所建议的:“语音平台运行时 11 和语音平台 SDK 11 不包括用于语音识别或语音合成(TTS 或文本转语音)的运行时语言。您必须单独安装它们。”

我通过从这里安装一种运行时语言解决了同样的问题: http://www.microsoft.com/en-us/download/details.aspx?id=27224

关于c# - 使用 Microsoft.Speech SDK 的文本转语音抛出 FileNotFoundException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11083302/

相关文章:

c# - 可以使用 LINQ 从字符串中提取关键字吗?

javascript - 语音合成 API 在说话时突出显示单词

java - Linux/Ubuntu - 在不使用 FreeTTS 的情况下从 Java 进行语音合成

.net - "Windows.Media.SpeechSynthesis"和 "System.Speech.Synthesis"有什么区别?

c# - Datagridview Winform C# 拖放行

c# - 使用网络摄像头读取二维码的库

javascript - 如何在网站上的语音合成中设置语言?

ios - 我可以在 Swift Playground 中加载 Alex Voice吗

javascript - 如何禁用提交按钮并在 ASP.NET 回发完成时启用按钮

c# - 查找格式正确的括号的所有组合