private async Task <string> GetReminderTitleAsync() { string title = ""; var titleIdentifierRegex = new Regex("(?<=(named |called |titled )).+"); var match = titleIdentifierRegex.Match(this.CommandString); if (match.Success) { title = match.Value; } else { // ask the user to give a title if listening is enabled, else tell the user to retry with a title if (Utils.IsListeningSettingEnabled()) { TextToSpeechEngine.SpeakText(this.MediaElement, "Sure, what's the title of the reminder?"); await SpeechRecognitionManager.RequestListen(this.GetType(), (text) => title = text); } else { // title should be null, which will be used in the calling method to tell the user that title is required title = null; } } return(title); }
public async override void PerformAction() { CommandString = CommandString.ToUpper(); string strDestination = ""; if (CommandString.Contains(" TO ")) { strDestination = CommandString.Substring(CommandString.IndexOf(" TO ") + 4); } else { // have bob ask the user where they want to go TextToSpeechEngine.SpeakText(this.MediaElement, "Sure, where do you want to go?"); // sleep the thread to give bob enough time to speak if (!await SpeechRecognitionManager.RequestListen(this.GetType(), (text) => { strDestination = text; GetDirections(text); })) { string message = "Sorry, but something went wrong. To get directions, say \"Hey Bob, how do I get to thePlace\""; TextToSpeechEngine.SpeakText(this.MediaElement, message); this.ShowMessage(message); } else { ProvideDirectionsSuccessMessage(strDestination); } } if (StringUtils.IsNotBlank(strDestination)) { GetDirections(strDestination); ProvideDirectionsSuccessMessage(strDestination); } }
public override async void PerformAction() { Action <string> repeatAction = (text) => { this.ClearArea(); TextToSpeechEngine.SpeakText(this.MediaElement, $"{text}"); this.ShowMessage($"You said {text}"); }; var executedSuccessfully = await SpeechRecognitionManager.RequestListen(this.GetType(), repeatAction); if (!executedSuccessfully) { this.ClearArea(); string message = "Something went wrong with listening to you, so I cannot repeat after you. Do you have voice activation set to off in the app settings or system settings?"; TextToSpeechEngine.SpeakText(this.MediaElement, message); this.ShowMessage(message); } }