TTS for Chinese is throwing SAPI ERROR E_FAIL

1.9k Views Asked by At

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();
        }
    }
}

Exception that the code is throwing is

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

Please help me in resolving this issue

1

There are 1 best solutions below

2
On

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

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

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

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.