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 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 void Question_Answered(string answer) { oRecognizer.UnloadAllGrammars(); 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"); sendMessage(gCurrentUser, 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 = ""; }