gpt4 book ai didi

c# - 中文 TTS 失败,而英语有效

转载 作者:行者123 更新时间:2023-11-30 18:21:24 26 4
gpt4 key购买 nike

我刚刚安装了 Microsoft speech 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);
}
}
}

在另一个问题中我发现了这个 answer ,其中指出(自?)Windows 8.1 中缺少重要文件,但没有说明如何获取这些的任何方法。

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

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

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

再次针对我代码中的同一行。

最佳答案

由 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.

关于c# - 中文 TTS 失败,而英语有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35541173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com