public Boolean SendPattern(string match) { try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); //oRecognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(oRecognizer_StateChanged); } catch (Exception ex) { Log.Error("Unable to configure oRecognizer", ex); } oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_OSA_Grammar(oRecognizer); //REPLACE WITH GRAMMAR // string patternName = Common.MatchPattern(match,""); // if (patternName != "") // { // OSAEScriptManager.RunPatternScript(patternName, "", "REST Service"); // return true; // } // else return(false); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Load_App_Name(); OSAE.OSAEObject tempAlias = OSAE.OSAEObjectManager.GetObjectByName(gSystemName); if (tempAlias.Alias.Length > 0) { gSystemName = tempAlias.Alias; } try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); oRecognizer.AudioStateChanged += new EventHandler <AudioStateChangedEventArgs>(oRecognizer_StateChanged); } catch (Exception ex) { AddToLog("Unable to configure oRecognizer"); AddToLog("Error: " + ex.Message); } Load_Settings(); Common.CheckComputerObject(gAppName); oRecognizer = OSAEGrammar.Load_User_Grammar(oRecognizer); try { gSpeechPlugin = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Can Hear this Plugin").Value.ToString(); if (gSpeechPlugin == "") { gSpeechPlugin = "Speech"; OSAEObjectPropertyManager.ObjectPropertySet(gAppName, "Can Hear this Plugin", "Speech", "VR Client"); } AddToLog("-- I will ignore speech from: " + gSpeechPlugin); oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_Voice_Grammars(oRecognizer); SaveGrammars(); AddToLog("Finished Loading..."); AddToLog("_______________________________________________"); AddToLog("Who are you?"); Thread t1 = new Thread(delegate() { oRecognizer.SetInputToDefaultAudioDevice(); oRecognizer.RecognizeAsync(RecognizeMode.Multiple); while (!gAppClosing) { Thread.Sleep(333); } }); t1.Start(); } catch (Exception ex) { AddToLog("Unable to set Default Audio Device. Check Sound Card."); AddToLog("Error: " + ex.Message); } }
public void Question_Answered(string answer) { oRecognizer.UnloadAllGrammars(); oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_OSA_Grammar(oRecognizer); sendMessage(Common.PatternParse("Setting " + gAnswerObject + "'s " + gAnswerProperty + " to " + answer), gCurrentAddress); Log.Info(Common.PatternParse("Setting " + gAnswerObject + "'s " + gAnswerProperty + " to " + answer)); OSAEObjectPropertyManager.ObjectPropertySet(gAnswerObject, gAnswerProperty, answer, gCurrentUser); //Trust is enforced in the storedProc, but maybe it can be checked here for better replies. gAnswerObject = ""; gAnswerProperty = ""; }
public override void RunInterface(string pluginName) { gAppName = pluginName; Log = new General.OSAELog(gAppName); try { gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value); } catch { Log.Info("The JABBER Object Type seems to be missing the Debug Property!"); } Log.Info("Debug Mode Set to " + gDebug); OwnTypes(); OSAE.OSAEObject tempAlias = OSAE.OSAEObjectManager.GetObjectByName(gSystemName); if (tempAlias.Alias.Length > 0) { gSystemName = tempAlias.Alias; } try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); //oRecognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(oRecognizer_StateChanged); } catch (Exception ex) { Log.Error("Unable to configure oRecognizer", ex); } oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); Log.Info("Load_Direct_Grammar completed"); oRecognizer = OSAEGrammar.Load_Voice_Grammars(oRecognizer); Log.Info("Load_Voice_Grammars completed"); oRecognizer = OSAEGrammar.Load_Text_Only_Grammars(oRecognizer); Log.Info("Load_Text_Only_Grammars completed"); // Subscribe to Events xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin); xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart); xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd); xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem); xmppCon.OnPresence += new agsXMPP.protocol.client.PresenceHandler(xmppCon_OnPresence); xmppCon.OnAuthError += new XmppElementHandler(xmppCon_OnAuthError); xmppCon.OnError += new ErrorHandler(xmppCon_OnError); xmppCon.OnClose += new ObjectHandler(xmppCon_OnClose); xmppCon.OnMessage += new agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage); connect(); }
public override void RunInterface(string pluginName) { gAppName = pluginName; if (OSAEObjectManager.ObjectExists(gAppName)) { Log.Info("Found the Jabber plugin's Object (" + gAppName + ")"); } try { gDebug = Convert.ToBoolean(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Debug").Value); } catch { Log.Info("The JABBER Object Type seems to be missing the Debug Property!"); } Log.Info("Debug Mode Set to " + gDebug); OwnTypes(); try { oRecognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(oRecognizer_SpeechRecognized); //oRecognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(oRecognizer_StateChanged); } catch (Exception ex) { Log.Error("Unable to configure oRecognizer", ex); } oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_OSA_Grammar(oRecognizer); // Subscribe to Events xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin); xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart); xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd); xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem); xmppCon.OnPresence += new agsXMPP.protocol.client.PresenceHandler(xmppCon_OnPresence); xmppCon.OnAuthError += new XmppElementHandler(xmppCon_OnAuthError); xmppCon.OnError += new ErrorHandler(xmppCon_OnError); xmppCon.OnClose += new ObjectHandler(xmppCon_OnClose); xmppCon.OnMessage += new agsXMPP.protocol.client.MessageHandler(xmppCon_OnMessage); connect(); }
public void Ask_Question(string address) { //OSAEObjectProperty prop = OSAEObjectPropertyManager.GetObjectPropertyValue("Vaughn", "JabberID"); DataSet dataset = new DataSet(); dataset = OSAESql.RunSQL("SELECT Question,object_name,property_name,property_datatype,property_object_type,interest_level FROM osae_v_interests ORDER BY interest_level DESC LIMIT 1"); if (dataset.Tables[0].Rows.Count > 0) { string sQuestion = dataset.Tables[0].Rows[0]["Question"].ToString(); sendMessage(Common.PatternParse(sQuestion), address); //Unload All grammars oRecognizer.UnloadAllGrammars(); //Load Answer grammer based on Property Object Type plus Unknown and None oRecognizer = OSAEGrammar.Load_Property_Grammar(oRecognizer, dataset.Tables[0].Rows[0]["property_datatype"].ToString(), dataset.Tables[0].Rows[0]["property_object_type"].ToString()); //set a AskingQuestionVariables so recognition can run an QuestionedAnswered routine gAnswerObject = dataset.Tables[0].Rows[0]["object_name"].ToString(); gAnswerProperty = dataset.Tables[0].Rows[0]["property_name"].ToString(); Log.Info("Asking: " + sQuestion + " (" + gAnswerObject + "," + gAnswerProperty + ")"); } }
private void oRecognizer_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e) { try { RecognitionResult result = e.Result; SemanticValue semantics = e.Result.Semantics; string scriptParameter = ""; if (e.Result.Semantics.ContainsKey("PARAM1")) { string temp = e.Result.Semantics["PARAM1"].Value.ToString().Replace("'s", "").Replace("'S", ""); if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY") { temp = gCurrentUser; } if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR") { temp = "SYSTEM"; } scriptParameter = temp; if (e.Result.Semantics.ContainsKey("PARAM2")) { temp = e.Result.Semantics["PARAM2"].Value.ToString().Replace("'s", "").Replace("'S", ""); if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY") { temp = gCurrentUser; } if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR") { temp = "SYSTEM"; } scriptParameter += "," + temp; if (e.Result.Semantics.ContainsKey("PARAM3")) { temp = e.Result.Semantics["PARAM3"].Value.ToString().Replace("'s", "").Replace("'S", ""); if (temp.ToUpper() == "I" || temp.ToUpper() == "ME" || temp.ToUpper() == "MY") { temp = gCurrentUser; } if (temp.ToUpper() == "YOU" || temp.ToUpper() == "YOUR") { temp = "SYSTEM"; } scriptParameter += "," + temp; } } } // scriptParameter = scriptParameter.Replace(); string sResults = ""; if (e.Result.Semantics.ContainsKey("ANSWER")) { Question_Answered(e.Result.Semantics["ANSWER"].Value.ToString()); } else { if (result.Grammar.Name.ToString() == "Direct Match") { Log.Debug("Searching for: " + sResults); sResults = OSAEGrammar.SearchForMeaning(result.Text, scriptParameter, gCurrentUser); } else { Log.Debug("Searching for: " + sResults); sResults = OSAEGrammar.SearchForMeaning(result.Grammar.Name.ToString(), scriptParameter, gCurrentUser); } } Log.Info("Search Results: " + sResults); } catch (Exception ex) { Log.Error("Error in _SpeechRecognized!", ex); } }
private void ProcessInput(string sRaw, string sInput, string scriptParamaters) { DataSet dsResults = new DataSet(); try { if (wakeList.Contains(sInput) && gVRMuted == true) { gVRMuted = false; lblStatus.Content = "I am awake."; } else if (sleepList.Contains(sInput) && gVRMuted == false) { gVRMuted = true; lblStatus.Content = "I am sleeping. Zzzz"; } else if (sleepList.Contains(sInput) && gVRMuted == true) { return; } // gSpeechPlugin; string temp = OSAEObjectPropertyManager.GetObjectPropertyValue(gSpeechPlugin, "Speaking").Value.ToString().ToLower(); if (temp.ToLower() == "false") { if ((gVRMuted == false) || (sleepList.Contains(sInput))) { if (sInput.StartsWith("This is [OBJECT]")) { AddToLog("Heard: " + sRaw); if (scriptParamaters != "") { if (gUser == scriptParamaters) { return; } OSAEObject obj = OSAEObjectManager.GetObjectByName(scriptParamaters); if (obj.Alias.Length > 0) { gUser = obj.Alias; } else { gUser = obj.Name; } AddToLog("I am talking to " + gUser); lblObjectTalking.Content = "I am talking to " + gUser; string sText = OSAEGrammar.SearchForMeaning(sInput, scriptParamaters, gUser); return; } } if (gUser == "") { AddToLog("I must know who I am talking with."); //return; } try { string sLogEntry = "Heard: " + sRaw; string sText = OSAEGrammar.SearchForMeaning(sInput, scriptParamaters, gUser); if (sText.Length > 0) { sLogEntry += ". Ran: " + sText; OSAEObjectPropertyManager.ObjectPropertySet(gUser, "Communication Method", "Speech", gUser); } AddToLog(sLogEntry); } catch {} } } } catch (Exception ex) { AddToLog("Error in _SpeechRecognized: " + ex.Message); } }
private void ProcessInput(string sRaw, string sInput, string scriptParamaters) { DataSet dsResults = new DataSet(); try { if (wakeList.Contains(sInput) && gVRMuted == true) { gVRMuted = false; lblStatus.Content = "I am awake."; } else if (sleepList.Contains(sInput) && gVRMuted == false) { gVRMuted = true; lblStatus.Content = "I am sleeping. Zzzz"; } else if (sleepList.Contains(sInput) && gVRMuted == true) { return; } if (sInput.StartsWith("This is [OBJECT]")) { AddToLog("Heard: " + sRaw); if (scriptParamaters != "") { gUser = scriptParamaters; AddToLog("I am talking to " + gUser); lblObjectTalking.Content = "I am talking to " + gUser; string sText = OSAEGrammar.SearchForMeaning(sInput, scriptParamaters, gUser); oRecognizer.UnloadAllGrammars(); oRecognizer = OSAEGrammar.Load_Direct_Grammar(oRecognizer); oRecognizer = OSAEGrammar.Load_OSA_Grammar(oRecognizer); SaveGrammars(); } } // gSpeechPlugin; String temp = OSAEObjectPropertyManager.GetObjectPropertyValue(gSpeechPlugin, "Speaking").Value.ToString().ToLower(); if (temp.ToLower() == "false") { if ((gVRMuted == false) || (sleepList.Contains(sInput))) { try { string sLogEntry = "Heard: " + sRaw; //string sText = OSAE.Common.MatchPattern(sInput,gUser); //string sText = MatchPattern(sInput,gUser); string sText = OSAEGrammar.SearchForMeaning(sInput, scriptParamaters, gUser); if (sText.Length > 0) { sLogEntry += ". Ran: " + sText; } OSAEObjectPropertyManager.ObjectPropertySet(gUser, "Communication Method", "Speech", gUser); AddToLog(sLogEntry); } catch {} } } } catch (Exception ex) { AddToLog("Error in _SpeechRecognized: " + ex.Message); } }