我刚刚安装了Microsoft语音SDK 11,并添加了两种不同的运行时语言,分别为英语和中文。
英语似乎运行正常,但中文会出现以下错误
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
我在代码中需要再次使用同一行。