protected async override void OnNavigatedTo(NavigationEventArgs e) { // Prompt the user for permission to access the microphone. This request will only happen // once, it will not re-prompt if the user rejects the permission. bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission(); if (permissionGained) { await InitializeSpeechRecognizer(); } else { resultTextBlock.Text = "Permission to access capture resources was not given by the user, reset the application setting in Settings->Privacy->Microphone."; btnContinuousRecognize.IsEnabled = false; } // SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeAsync(); // HandleRecognitionResult(speechRecognitionResult); }
/// <summary> /// Triggered every time the page is navigated to. /// </summary> protected async override void OnNavigatedTo(NavigationEventArgs e) { if (initializedOxford) { UpdateWhitelistedVisitors(); } bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission(); if (permissionGained) { InitializeRecognizer(); } else { resultTextBlock.Visibility = Visibility.Visible; resultTextBlock.Text = "Permission to access capture resources was not given by the user; please set the application setting in Settings->Privacy->Microphone."; } }