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); } }
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); }
protected override void OnEnabling(EnablingEventArgs e) { try { SpeechRecognitionManager.Recognize(phrase, Recognized); } catch (InvalidOperationException ex) { ErrorLog.AddError(ErrorType.Failure, ex.Message); e.Cancel = true; return; } }
protected override void OnEnabling(EnablingEventArgs e) { try { SpeechRecognitionManager.Recognize(phrase, Recognized); } catch { ErrorLog.AddError(ErrorType.Failure, "Unable to start up the Speech Recognition Engine"); e.Cancel = true; return; } }
private async void RequestMicrophoneAcessIfUserWantsVoiceDetection() { if (Utils.IsListeningSettingEnabled()) { if (await AudioCapturePermissions.RequestMicrophonePermission()) { SpeechRecognitionManager.StartListeningForMainPage(performActionFromCommandBoxText, this.CommandBox); } else { TextToSpeechEngine.SpeakText(this.media, "Sorry, but something went wrong with setting up your microphone. You cannot use me through speech, but you can still use the command bar at the bottom of the screen."); } } }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { // initialise the speech recognition manager recognitionManager = new SpeechRecognitionManager(grammarFile); // register the event for when speech is detected recognitionManager .SpeechRecognizer .ContinuousRecognitionSession .ResultGenerated += RecognizerResultGenerated; // compile the grammar file await recognitionManager.CompileGrammar(); }
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); } }
public MainWindow() { InitializeComponent(); this.Closed += ClosedWindow; kinectManager = new KinectManager(); kinectManager.Start(); bodyManager = new BodyManager(kinectManager); speechRecognitionManager = new SpeechRecognitionManager(kinectManager.Sensor); speechRecognitionManager.RecognizedCommandEventHandler += RecognizedCommand; mainPanel.CommandEventHandler += MainPanelCommand; trainPanel.KinectManager = kinectManager; trainPanel.BodyManager = bodyManager; exercisePanel.KinectManager = kinectManager; exercisePanel.BodyManager = bodyManager; focusedPanel = FocusedPanel.Main; }
protected override void OnDisabled(DisabledEventArgs e) { SpeechRecognitionManager.CancelRecognize(phrase, Recognized); }
private void button3_Click(object sender, EventArgs e) { SpeechRecognitionManager mn = new SpeechRecognitionManager(); mn.ManageVoiceInstructions(Parse); }