这是我的中文TTS代码,虽然中文TTS引擎安装成功但说话功能失败
using Microsoft.Speech.Synthesis;
using System.Globalization;
namespace TTS3
{
class Program
{
static void Main(string[] args)
{
//CultureInfo=new CultureInfo("zh-CN");
SpeechSynthesizer synth = new SpeechSynthesizer();
// Output information about all of the installed voices.
foreach (InstalledVoice voice in synth.GetInstalledVoices(new CultureInfo("zh-CN")))
{
synth.SelectVoice(voice.VoiceInfo.Name);
//Console.WriteLine(synth.Voice.Description);
synth.SetOutputToWaveFile("C:\\Users\\surabhi\\Desktop\\yes.wav");
synth.Speak("你好世界");
break;
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
代码抛出的异常是
Unhandled Exception: System.InvalidOperationException: Speak error '80004005'. -
--> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been r
eturned from a call to a COM component.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 e
rrorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode
)
at Microsoft.Speech.Internal.Helpers.ExceptionFromSapiError(SAPIErrorCodes er
rorCode)
--- End of inner exception stack trace ---
at Microsoft.Speech.Synthesis.SpeechSynthesizer.SpeakPrompt(Prompt prompt, Bo
olean async)
at Microsoft.Speech.Synthesis.SpeechSynthesizer.Speak(Prompt prompt)
at Microsoft.Speech.Synthesis.SpeechSynthesizer.Speak(String textToSpeak)
at TTS3.Program.Main(String[] args) in c:\Users\surabhi\Documents\Visual Stud
io 2013\Projects\TTS3\TTS3\Program.cs:line 23
请帮我解决这个问题
答案 0 :(得分:3)
在Windows 8.1和Windows 8.0之间,删除了两个对使用Server Speech API至关重要的文件。这些是chsbrkr.dll和chtbrkr.dll,它们将位于Windows 8.0的Windows目录中。根据您的SDK和Windows 8.0版本(x86 vs x64),从Windows中选择x86 vs x64版本也很重要。例如,在使用32位dll的64位Windows 8.1环境中,您应该将这两个文件放在
中C:\ Program Files(x86)\ Common Files \ Microsoft Shared \ Speech \ TTS \ v11.0
希望微软能解决这些问题(虽然我被告知他们不会)或正式允许分发(祝你好运......)。
顺便说一句,你不应该在Windows XP到Windows 8.0中看到这个错误。
更新。我相信这些文件用于将中文拆分为TTS来处理的块。没有它们,中文TTS将失败并显示错误。