例外:在尝试语音识别之前不接受语音隐私政策

Exception: The speech privacy policy was not accepted prior to attempting a speech recognition

我必须从哪里接受语音识别政策?

这是代码

public async void display()
{
    SpeechRecognizer rec = new SpeechRecognizer();
    await rec.CompileConstraintsAsync();
    rec.Timeouts.InitialSilenceTimeout = TimeSpan.FromSeconds(5);
    rec.Timeouts.EndSilenceTimeout = TimeSpan.FromSeconds(20);
    rec.UIOptions.AudiblePrompt = "I am listening";
    rec.UIOptions.ShowConfirmation = true;
    rec.UIOptions.IsReadBackEnabled = true;
    rec.Timeouts.BabbleTimeout = TimeSpan.FromSeconds(5);
    SpeechRecognitionResult result = await rec.RecognizeAsync(); // Error here

    if (result!=null)
    {
        textBlock.Text= result.Text;
    }
}

这是语音、墨迹书写和打字下的设置。 首先,转到“设置”并单击 "Time & Language"。 接下来,从左侧的菜单中 select "Speech"。 之后,按 "Speech, inking & typing privacy settings"。 只需按下名为 "Get to know me" 的按钮即可。 然后,单击弹出窗口以打开设置。 之后,任何使用语音识别 API 的软件都可以使用。

告诉用户打开的有用方法是...

catch (System.Runtime.InteropServices.COMException e) when (e.HResult == unchecked((int)0x80045509))
//privacyPolicyHResult
//The speech privacy policy was not accepted prior to attempting a speech recognition.
{
    ContentDialog Dialog = new ContentDialog()
    {
        Title = "The speech privacy policy was not accepted",
        Content = "You need to turn on a button called 'Get to know me'...",
        PrimaryButtonText = "Shut up",
        SecondaryButtonText = "Shut up and show me the setting"
    };
    if (await Dialog.ShowAsync() == ContentDialogResult.Secondary)
    {
        const string uriToLaunch = "ms-settings:privacy-speechtyping";
        //"" + 
        //"was-not-accepted-prior-to-attempting-a-spee/43083877#43083877";
        var uri = new Uri(uriToLaunch);

        var success = await Windows.System.Launcher.LaunchUriAsync(uri);

        if (!success) await new ContentDialog
        {
            Title = "Oops! Something went wrong...",
            Content = "The settings app could not be opened.",
            PrimaryButtonText = "Shut your mouth up!"
        }.ShowAsync();
    }
}

More ways to launch the Settings app