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);
        }
Example #2
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 #3
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 #4
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); }
        }