3

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

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();
4

2 回答 2

4

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

于 2013-10-13T12:40:13.977 回答
0

在 Windows 通用应用(UWP 应用)中,使用SpeechSynthetizer 需要麦克风功能。(我不知道为什么,但是一旦启用,我就再也没有得到异常了)

于 2015-05-30T01:41:20.740 回答