private void ContinuousRecognitionSession_ResultGenerated(SR.SpeechContinuousRecognitionSession sender, SR.SpeechContinuousRecognitionResultGeneratedEventArgs args) { if (args.Result.Status == SR.SpeechRecognitionResultStatus.Success) { Debug.WriteLine("Result Text:{0}, Confidence:{1}({2:F4}), Constraint:{3})", args.Result.Text, args.Result.Confidence, args.Result.RawConfidence, (args.Result.Constraint != null) ? args.Result.Constraint.Tag : "<No tag>"); if ( (args.Result.Confidence == SR.SpeechRecognitionConfidence.High) || (args.Result.Confidence == SR.SpeechRecognitionConfidence.Medium)) { switch (args.Result.Constraint.Tag) { case "EnableCommanding": ProcessSpeechStatusChangeCommand(args.Result); break; case "Commands": ProcessSpeechCommand(args.Result); break; default: Debug.WriteLine($"**** Unknown constraint '{args.Result.Constraint.Tag}'"); break; } } } else { Debug.WriteLine("Result: status({0})", args.Result.Status); } }
private async void ContinuousRecognitionSession_ResultGenerated(Windows.Media.SpeechRecognition.SpeechContinuousRecognitionSession sender, Windows.Media.SpeechRecognition.SpeechContinuousRecognitionResultGeneratedEventArgs args) { var sResult = args.Result; processInfo(sResult); }
private async void ContinuousRecognitionSession_ResultGenerated(Windows.Media.SpeechRecognition.SpeechContinuousRecognitionSession sender, Windows.Media.SpeechRecognition.SpeechContinuousRecognitionResultGeneratedEventArgs args) { Debug.WriteLine(JsonConvert.SerializeObject(args.Result)); if (args.Result.Confidence == Windows.Media.SpeechRecognition.SpeechRecognitionConfidence.High || args.Result.Confidence == Windows.Media.SpeechRecognition.SpeechRecognitionConfidence.Medium) { await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { HandleRecognitionResult(args.Result); }); } else { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Debug.WriteLine("I'm sorry I did not understand your command. Please say again"); }); } }
private async void ContinuousRecognitionSession_ResultGenerated(Windows.Media.SpeechRecognition.SpeechContinuousRecognitionSession sender, Windows.Media.SpeechRecognition.SpeechContinuousRecognitionResultGeneratedEventArgs args) { var sResult = args.Result; processInfo(sResult); //if (sResult.SemanticInterpretation.Properties.ContainsKey("TURNON")&&sResult.SemanticInterpretation.Properties["TURNON"][0].ToString() != "...") //{ // string objectX = sResult.SemanticInterpretation.Properties["TURNON"][0].ToString(); // var messageDialog = new Windows.UI.Popups.MessageDialog(objectX + " is turned on.", "Text spoken"); // await messageDialog.ShowAsync(); // return; //} //if (sResult.SemanticInterpretation.Properties.ContainsKey("TURNOFF") && sResult.SemanticInterpretation.Properties["TURNOFF"][0].ToString() != "...") //{ // string objectX = sResult.SemanticInterpretation.Properties["TURNOFF"][0].ToString(); // var messageDialog = new Windows.UI.Popups.MessageDialog(objectX + " is turned off.", "Text spoken"); // await messageDialog.ShowAsync(); // return; //} //if (sResult.SemanticInterpretation.Properties.ContainsKey("TURNONALL") && sResult.SemanticInterpretation.Properties["TURNONALL"][0].ToString() != "...") //{ // string objectX = sResult.SemanticInterpretation.Properties["TURNONALL"][0].ToString(); // var messageDialog = new Windows.UI.Popups.MessageDialog(String.Format("All {0} are turned on.",objectX)); // await messageDialog.ShowAsync(); // return; //} //if (sResult.SemanticInterpretation.Properties.ContainsKey("TURNOFFALL") && sResult.SemanticInterpretation.Properties["TURNOFFALL"][0].ToString() != "...") //{ // string objectX = sResult.SemanticInterpretation.Properties["TURNOFFALL"][0].ToString(); // var messageDialog = new Windows.UI.Popups.MessageDialog(String.Format("All {0} are turned off.", objectX)); // await messageDialog.ShowAsync(); // return; //} }