public DialogsViewModel(ISpeechDialogs dialogs, ITextToSpeech tts) { this.List = new List <ListItemViewModel> { new ListItemViewModel { Text = "Actions", Command = new Command(() => dialogs.Actions(new ActionsConfig("Choose your destiny") .SetShowDialog(this.ShowDialogs) .SetSpeakChoices(true) .Choice("Fatality", () => tts.Speak("Flawless Victory")) .Choice("Friendship", () => tts.Speak("Friendship")) .Choice("Bability", () => tts.Speak("Cute")) )) }, new ListItemViewModel { Text = "Confirm", Command = new Command(async() => { var result = await dialogs.Confirm("Shutdown your phone?", "Yes", "No", this.ShowDialogs); tts.Speak(result ? "Your phone will now self destruct" : "Too Bad"); }) }, new ListItemViewModel { Text = "Prompt", Command = new Command(async() => { var result = await dialogs.Prompt("Tell me your life story.... quickly!"); tts.Speak(result + " - BORING"); }) } }; }
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}"); }); }