public ConversationViewModel(ISpeechRecognizer speech, ITextToSpeech tts) { this.speech = speech; this.tts = tts; this.Start = new Command(() => this.DoConversation()); speech.WhenListeningStatusChanged().Subscribe(x => this.IsListening = x); }
public DictationViewModel(ISpeechRecognizer speech, IUserDialogs dialogs) { IDisposable token = null; speech .WhenListeningStatusChanged() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => this.ListenText = x ? "Stop Listening" : "Start Dictation" ); this.ToggleListen = ReactiveCommand.Create(() => { if (token == null) { if (this.UseContinuous) { token = speech .ContinuousDictation() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe( x => this.Text += " " + x, ex => dialogs.Alert(ex.ToString()) ); } else { token = speech .ListenUntilPause() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe( x => this.Text = x, ex => dialogs.Alert(ex.ToString()) ); } } else { token.Dispose(); token = null; } }); }
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 DictationViewModel(ISpeechRecognizer speech, IDialogs dialogs) { speech .WhenListeningStatusChanged() .SubOnMainThread(x => this.IsListening = x); this.ToggleListen = ReactiveCommand.Create(() => { if (this.IsListening) { this.Deactivate(); } else { if (this.UseContinuous) { speech .ContinuousDictation() .SubOnMainThread( x => this.Text += " " + x, ex => dialogs.Alert(ex.ToString()) ) .DisposedBy(this.DeactivateWith); } else { speech .ListenUntilPause() .SubOnMainThread( x => this.Text = x, ex => dialogs.Alert(ex.ToString()) ) .DisposedBy(this.DeactivateWith); } } }); }
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}"); }); }