中文TTS抛出SAPI ERROR E_FAIL [英] TTS for Chinese is throwing SAPI ERROR E_FAIL

查看:34
本文介绍了中文TTS抛出SAPI ERROR E_FAIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的中文TTS代码,虽然中文TTS引擎安装成功,但在speak功能中失败

This is my code for Chinese TTS which is failing in the speak function although Chinese TTS engine is installed successfully

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

请帮我解决这个问题

推荐答案

在 Windows 8.1 和 Windows 8.0 之间,删除了两个对于使用服务器语音 API 至关重要的文件.它们是 chsbrkr.dll 和 chtbrkr.dll,它们将位于 Windows 8.0 的 Windows 目录中.根据您的 SDK 和 Windows 8.0 版本(x86 与 x64)从 Windows 中选择 x86 与 x64 版本也很重要.例如,在 64 位 Windows 8.1 环境中,使用 32 位 dll,您应该将这两个文件放在

Between Windows 8.1 and Windows 8.0, two files were dropped that are critical for using the Server Speech API. These are chsbrkr.dll and chtbrkr.dll which will be in the Windows directory in Windows 8.0. It is also important to choose the x86 vs x64 versions from Windows depending on your SDK and Windows 8.0 version (x86 vs x64). For example, in a 64-bit Windows 8.1 environment, using 32-bit dll's, you should place the two files in

C:\Program Files (x86)\Common Files\Microsoft Shared\Speech\TTS\v11.0

C:\Program Files (x86)\Common Files\Microsoft Shared\Speech\TTS\v11.0

希望微软会修复这些问题(尽管我被告知他们不会)或正式允许分发(祝你好运......).

Hopefully, Microsoft will fix these (though I am told they will not) or officially allow for distribution (good luck...).

顺便说一句,您不应该在 Windows XP 到 Windows 8.0 中看到此错误.

BTW, you should not see this error in Windows XP through Windows 8.0.

更新.我相信这些文件用于将中文分解成块以供 TTS 处理.没有它们,中文 TTS 将失败并显示错误.

Update. I believe these files are used to break up Chinese into chunks for the TTS to handle. Without them, the Chinese TTS will fail with the error posted.

这篇关于中文TTS抛出SAPI ERROR E_FAIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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