文本到语音在Windows Store应用使用语音合成
问题描述:
我正在运行的世界,你好 我这个代码样本是文本到语音在Windows Store应用使用语音合成
private async void Button_Click(object sender, RoutedEventArgs e)
{
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello World");
var mediaElement = new MediaElement();
mediaElement.SetSource(stream,stream.ContentType);
mediaElement.Play();
}
当我调试它,我得到一个错误:
An exception of type 'System.IO.FileNotFoundException' occurred in SunnahForKids.exe but was not handled in user code
Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
答
要求
最低支持的客户端:Windows 8.1中
最低支持的服务器:在Windows Server 2012 R2
最低支持电话:Windows Phone的8.1 [Windows运行时应用的广告仅]
命名空间:Windows.Media.SpeechSynthesis时,Windows :: Media :: SpeechSynthesis [C++]
答
如果您使用Dependency walker查看system.speech.dll的依赖关系,它会告诉您 “错误:找到具有不同CPU类型的模块。” 在Visual Studio中将CPU设置为x64可能会解决您的问题。这个对我有用。
答
这可能是因为语音未安装在设备上。要解决这个问题,只需添加一个try catch块,并且只有在安装了与您的应用的区域和语言相关的语音时才会“发言”。否则它将运行而不会说话。
你确定所有被引用的DLL都可用吗? – Quintium