初始化 SpeechSynthesizer 时出现 UnauthorizedAccessException [英] UnauthorizedAccessException when initializing SpeechSynthesizer

查看:39
本文介绍了初始化 SpeechSynthesizer 时出现 UnauthorizedAccessException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Microsoft 的 SpeechSynthesizer 为我的 Windows Phone 应用程序创建音频输出.我用这个代码

I'm using Microsofts SpeechSynthesizer to create audio output for my Windows Phone app. I use this code

private async void TextToSpeech_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
    SpeechSynthesizer synth = new SpeechSynthesizer();

    await synth.SpeakTextAsync("You have a meeting with Peter in 15 minutes.");
}

我收到此异常:

{System.UnauthorizedAccessException: Access is denied.

at Windows.Phone.Speech.Synthesis.SpeechSynthesizer..ctor()
at NerdQuiz.Question.<TextToSpeech_Tap>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)}

我发现错误发生在

new SpeechSynthesizer();

推荐答案

确保您已将能力 ID_CAP_SPEECH_RECOGNITION 添加到应用程序清单 (WMAppManifest.xml).

Make sure you have added the capability ID_CAP_SPEECH_RECOGNITION to the application manifest (WMAppManifest.xml).

这篇关于初始化 SpeechSynthesizer 时出现 UnauthorizedAccessException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆