使用语音合成器在Windows应用商店应用中使用文本转换语音

时间:2014-02-09 20:43:10

标签: c# text-to-speech windows-8.1

我正在运行Hello world的示例 我的代码是

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)

3 个答案:

答案 0 :(得分:1)

来自MSDN Reference

<强>要求

支持的最低客户端:Windows 8.1

支持的最低服务器:Windows Server 2012 R2

支持的最低手机:Windows Phone 8.1 [仅限Windows运行时应用]

命名空间:Windows.Media.SpeechSynthesis,Windows :: Media :: SpeechSynthesis [C ++]

答案 1 :(得分:1)

这可能是因为设备上没有安装语音。要解决这个问题,只需添加一个try catch块,它就会只是&#34;说&#34;当安装与应用程序的区域和语言相关的语音时。否则它会在没有说话的情况下运行。

答案 2 :(得分:0)

如果您使用Dependency walker来查看system.speech.dll的依赖关系,它会告诉您 “错误:找到了具有不同CPU类型的模块。” 在Visual Studio中将CPU设置为x64可能会解决您的问题。它对我有用。