中文TTS失败,而英文工作

本文关键字:工作 文工作 TTS 失败 中文 | 更新日期: 2023-09-27 18:35:44

我刚刚安装了Microsoft语音 SDK 11,并为英语和中文添加了 2 种不同的运行时语言。

英语似乎运行良好,尽管中文给我抛出了这个错误

System.InvalidOperationException

附有其他信息

Speak error '80004005'

对于生产线

synth.Speak(s);

在下面的代码中

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

在另一个问题中,我找到了这个答案,其中指出(自?)Windows 8.1中缺少关键文件,但没有说明如何获取这些的任何方法。

我目前使用的是 64 位版本的 Windows 10。

编辑:我下载了文件chsbrkr.dll和chtbrkr.dll并得到以下新错误

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

再次用于我的代码中的同一行。

中文TTS失败,而英文工作

正如豆腐所发布的那样:https://stackoverflow.com/a/28042294/1212314

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

C:''程序文件 (x86)''通用文件''Microsoft 共享''语音''TTS''v11.0

希望Microsoft能解决这些问题(尽管我被告知他们不会)或正式允许分发(祝你好运......

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

更新。我相信这些文件是用来将中文分解成块供TTS处理的。没有它们,中文 TTS 将失败并发布错误。