private static void ResponseBoxGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { if (e.Result != null & e.Result.Confidence >= 0.825) { Task.Run(() => { writeToTextBox(e.Result.Text); }); DataStore.AddRecentCommand(e.Result.Text); if (e.Result.Text == "Ok") { if (AddUser.AddUserRunning == true) { UserDialogOk(); ResponseBoxResponse(new Response(CommandType.ResponseBox, DateTime.Now.TimeOfDay.Hours, "user dialog ok . ")); } else if (SelectUser.SelectUserRunning == true) { UserDialogOk(); ResponseBoxResponse(new Response(CommandType.ResponseBox, DateTime.Now.TimeOfDay.Hours, "user dialog ok . ")); } else { ProgramManager.SendOpenCommand(openRecogPhrase); GrammarManipulator.EnableCloseGrammar(); CloseResponseBoxEvent(); ResponseBoxResponse(new Response(CommandType.ResponseBox, DateTime.Now.TimeOfDay.Hours, e.Result.Text)); } } else if (e.Result.Text == "Cancel") { CloseResponseBoxEvent(); ResponseBoxResponse(new Response(CommandType.ResponseBox, DateTime.Now.TimeOfDay.Hours, e.Result.Text)); } else { writeToTextBox(""); //remove the text in the analyzed textbox } } }
private static void BasicGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { if (e.Result != null & e.Result.Confidence >= 0.85) { DataStore.AddRecentCommand(e.Result.Text); DataStore.AddToMessageDump(e.Result.Text); if (e.Result.Text.Contains("Open") | e.Result.Text.Contains("Execute") | e.Result.Text.Contains("Run") | e.Result.Text.Contains("Initialize") | e.Result.Text.Contains("Start")) { Task.Run(() => { writeToTextBox(e.Result.Text); }); try { ResponseBox.CreateResponseBox(); } catch (Exception ex) { DataStore.AddToErrorLog(string.Format("Main exception {0}\nMain exception stack trace {1}\nInner exception {2}\ninner Exception stack trace {3}", ex.Message, ex.StackTrace, ex.InnerException.Message, ex.InnerException.StackTrace)); } try { BasicResponse(new Response(CommandType.Open, DateTime.Now.TimeOfDay.Hours, e.Result.Text)); } catch (Exception excep) { DataStore.AddToErrorLog(string.Format("Main exception {0}\nMain exception stack trace {1}\nInner exception {2}\ninner Exception stack trace {3}", excep.Message, excep.StackTrace, excep.InnerException.Message, excep.InnerException.StackTrace)); } } else if (e.Result.Text.Contains("Search the web") | e.Result.Text.Contains("Search the internet")) { BasicResponse(new Response(CommandType.Search, DateTime.Now.TimeOfDay.Hours, e.Result.Text)); ProgramManager.SendOpenCommand("Google Chrome"); } else { try { Task.Run(() => { writeToTextBox(e.Result.Text); }); SystemOptions.OpenSystemCommandsDialog(); } catch (Exception ex) { DataStore.AddToErrorLog(string.Format("An exception occured. \nException Message : {0}\n Exception StackTrace : {1}", ex.Message, ex.StackTrace)); } try { BasicResponse(new Response(CommandType.Basic, DateTime.Now.TimeOfDay.Hours, e.Result.Text)); } catch (Exception excep) { DataStore.AddToErrorLog(string.Format("An exception occured. \nException Message : {0}\n Exception StackTrace : {1}", excep.Message, excep.StackTrace)); } } } }