Chinese TTS Fails, while English works

2019-02-19 03:44发布

问题:

I just installed the Microsoft speech SDK 11 and added 2 different Runtime languages for english and chinese.

English seems to run fine, though chinese throws me this error

System.InvalidOperationException

with additional information

Speak error '80004005'

for the line

synth.Speak(s);

in the following code

using System;
using Microsoft.Speech.Synthesis;

namespace SampleSynthesis
{
    class Program
    {
        static void Main(string[] args)
        {
            speakString(0, "Hello, I'm TTS.");
        }

        static void speakString(int i, String s)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();

            // Select a voice. 
            switch (i)
            {
                case 0:
                    synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-US, ZiraPro)");
                    break;
                case 1:
                    synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (zh-CN, HuiHui)");
                    break;
            }

            // Configure the audio output. 
            synth.SetOutputToWaveFile(@"C:\Users\David\Desktop\TTStest\test.wav");

            synth.Speak(s);
        }
    }
}

In another question I found this answer, which states that there are crucial files missing in (since?) windows 8.1, but doesn't state any method for how to acquire these.

I am currently using a 64bit version of windows 10.

EDIT: I downloaded the files chsbrkr.dll and chtbrkr.dll and get the following new error

An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.Speech.dll

again for the same line in my code.

回答1:

As posted by tofutim: https://stackoverflow.com/a/28042294/1212314

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.