在WP8.1仿真器中创建SpeechSynthesizer实例时未经授权的访问异常

时间:2014-07-20 07:25:07

标签: windows-phone-8.1 windows-phone-8-emulator

我试图重新创建MSDN网站上使用的simle Text to Speech示例。但是,每当代码创建SpeechSynthesizer类的实例时,它在WP8.1仿真器上运行时失败,并显示Unauthorized Acception错误。我目前没有可以测试的实际设备,看看这是否有所不同。

我的代码很简单:

    private async void TTS()
    {
        // The media object for controlling and playing audio.
        MediaElement mediaElement = new MediaElement();

        // The object for controlling the speech synthesis engine (voice).
        var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

        // Generate the audio stream from plain text.
        SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello World");

        // Send the stream to the media object.
        mediaElement.SetSource(stream, stream.ContentType);
        mediaElement.Play();
    }

我知道Windows 8.1中的SpeechSynthesizer存在问题,我在寻找解决问题时找到了解决方案,但对WP8.1 SpeechSynthesizer的问题几乎没有发现。有没有其他人遇到过这个问题并找到了解决办法?

1 个答案:

答案 0 :(得分:1)

您应该在Package.appxmanifest文件中添加一个DeviceCapability:

在DeviceCapability选项卡中,检查 麦克风 ,因为它可以访问麦克风的音频源,从而允许该应用从连接的麦克风录制音频。

看看这个图书馆:App capability declarations (Windows Runtime apps)

相关问题