本文介绍了uwp 语音识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个简单的 UWP 应用程序来测试语音识别功能,但是我有一些错误,它显示:System.UnauthorizedAccessException: '访问被拒绝.(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))'

I made a simple UWP application to test speech recognition function, But I have some error, it shows: System.UnauthorizedAccessException: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'

  public sealed partial class MainPage : Page
{

    public MainPage()
    {
        this.InitializeComponent();
    }

    SpeechRecognizer recognizer = new SpeechRecognizer();


    private async void Record_Click(object sender, RoutedEventArgs e)
    {

        var topUserLanguage = GlobalizationPreferences.Languages[0];
        var language = new Language(topUserLanguage);
        recognizer = new SpeechRecognizer(language);
        await recognizer.CompileConstraintsAsync();

        recognizer.Timeouts.InitialSilenceTimeout = TimeSpan.FromDays(1);

        var recordResult = await this.recognizer.RecognizeAsync();

        result.Text = recordResult.Text;


    }



}

推荐答案

右键单击解决方案浏览器面板中的 Package.appxmanifest 以启用麦克风功能

Right click the Package.appxmanifest in the solution explorer panel to enable microphone capaility

这篇关于uwp 语音识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 05:13