Example #1
0
        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);
            }
        }
Example #3
0
        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 = "";
        }
Example #4
0
        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();
        }
Example #5
0
        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();
        }
Example #6
0
        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); }
        }