/// <summary> /// Check if this feature is supported for your device /// </summary> /// <returns></returns> private async System.Threading.Tasks.Task <bool> ValidateSpeechRecognition() { if (!this.speech.IsSupported) { App.ShowToast("Speech recognition is not supported for this device at this moment.."); return(false); } else { var status = await speech.RequestPermission(); if (status != SpeechRecognizerStatus.Available) { App.AddLog("Permission denied for speech recognition"); App.ShowToast("Don't have the permission for the mic"); return(false); } } return(true); }
public DictationViewModel(ISpeechRecognizer speech) { IDisposable token = null; speech .WhenListeningStatusChanged() .Subscribe(x => this.ListenText = x ? "Stop Listening" : "Start Dictation" ); this.ToggleListen = new Command(async() => { if (speech.Status != SpeechRecognizerStatus.Available) { this.ListenText = "Problem with speech recognition engine - " + speech.Status; return; } var granted = await speech.RequestPermission(); if (!granted) { this.ListenText = "Invalid Permissions"; return; } if (token == null) { token = speech .ContinuousDictation() //.Catch<string, Exception>(ex => Observable.Return(ex.ToString())) .Subscribe(x => this.Text += " " + x); } else { token.Dispose(); token = null; } }); }
public ChatViewModel(ITextToSpeech tts, ISpeechRecognizer speech, ISpeechDialogs dialogs) { this.tts = tts; speech.WhenListeningStatusChanged().Subscribe(x => this.IsListening = x); this.Start = new Command(async() => { if (speech.Status != SpeechRecognizerStatus.Available) { await tts.Speak("Problem with speech recognition engine - " + speech.Status); return; } var granted = await speech.RequestPermission(); if (!granted) { await tts.Speak("Hey Dummy! Ya you! You didn't enable permissions for the microphone"); return; } var answer = await dialogs.Prompt("Hello, please tell me your name?"); await tts.Speak($"Hello {answer}"); }); }