2017-02-22 40 views
3

Откуда я должен принять политику распознавания речи?Исключение: Политика конфиденциальности речи не была принята до попытки распознавания речи

Вот код

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; 
    } 
} 

ответ

6

Это установка под Speech, черчение и типирования. Сначала перейдите в раздел «Настройки» и нажмите «Время & Язык». Settings app Затем выберите «Речь» в меню слева. Select from the menu После этого нажмите «Речь, красная &, набрав настройки конфиденциальности». Go to the real setting Просто нажмите кнопку «Узнай меня». The setting Затем нажмите всплывающее окно, чтобы включить настройку. One more step После этого будет работать любое программное обеспечение, использующее 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"; 
     //"http://stackoverflow.com/questions/42391526/exception-the-speech-privacy-policy-" + 
     //"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

Смежные вопросы