3

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

Sur123
  • 35
  • 9
  • Are you sure the voice is enabled? Check (from your code) `voice.Enabled`. – Eric Brown Dec 10 '14 at 17:57
  • yup it is TRUE.I checked – Sur123 Dec 11 '14 at 02:13
  • it is working perfectly fine for french, dont know why is it failing for chinese. – Sur123 Dec 12 '14 at 05:58
  • Which voice are you using? This might be a bug in the TTS engine. – Eric Brown Dec 12 '14 at 18:58
  • zh-CN HuiHui. Is it possible that sapi code in c++ which is making use of shelper.h is working fine and in c# Microsoft.Speech is not. Anywaz they are connected through some way.right? – Sur123 Dec 14 '14 at 10:05
  • something weird has happened, my c++ code which is using SAPI library is working fine because it it using Microsoft HuiHui Desktop-Chinese Simplified. Is it beacause of some conflict in the speech server tts and this voice.? – Sur123 Dec 15 '14 at 03:55
  • The [TTS engines for System.Speech.Synthesis and Microsoft.Speech.Synthesis are different](http://stackoverflow.com/questions/2977338/what-is-the-difference-between-system-speech-recognition-and-microsoft-speech-re/2982910#2982910). Are you sure you've installed the server TTS engine for zh-CN? – Eric Brown Dec 15 '14 at 19:06
  • Yes I have checked in the registry location HKEY_LOCAL_MACHINE\Software\Microsoft\SpeechServer\Voices\Tokens\v11.0\TTS_MS_zh_CN_HuiHui_11.0 is there. Although HKEY_LOCAL_MACHINE\Software\Microsoft\Speech\Voices\Tokens\v11.0\TTS_MS_ZH_CN_HUIHUI_11.0 is also present. Does this means there is a conflict of tts engines? – Sur123 Dec 16 '14 at 03:03
  • I found this question after having the same problem with Japanese (Windows 10, Speech v11). I don't have access to the DLLs to give them a try (and they might be for Chinese only), so I have no idea if it would solve the issue. – briantist Jul 08 '17 at 21:25

1 Answers1

5

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.

tofutim
  • 22,664
  • 20
  • 87
  • 148
  • Is it possible to get a link for this file ? Didn't work. See related issues : http://stackoverflow.com/questions/35541173/chinese-tts-fails-while-english-works – Adavo May 31 '16 at 01:15
  • This fixed my issue. Still a problem in Windows 10 also. – egfconnor May 02 '17 at 15:23