Exemplo n.º 1
0
        // ==========================================
        //  RECOGNIZE
        // ==========================================

        protected void SpeechRecognized(RecognitionResult rr)
        {
            // 1. Prevent while speaking
            if (WSRSpeakerManager.GetInstance().Speaking)
            {
                cfg.logWarning("ENGINE - " + Name, "REJECTED Speech while speaking : " + rr.Confidence + " Text: " + rr.Text);
                return;
            }

            // 2. Prevent while working
            XPathNavigator xnav = HandleSpeech(rr);

            if (xnav == null)
            {
                return;
            }

            // 3. Reset context timeout
            if (rr.Grammar.Name != "Dyn")
            {
                WSRSpeechManager.GetInstance().ResetContextTimeout();
            }
            else
            {
                cfg.logInfo("ENGINE - " + Name, "DYN reset to default context");
                WSRSpeechManager.GetInstance().SetContext("default");
                WSRSpeechManager.GetInstance().ForwardContext();
            }

            // 4. Track Audio Pitch
            TrackPitch(rr);

            // 5. Reset Speech Buffer
            WSRSpeakerManager.GetInstance().SpeechBuffer = "";

            // 6. Hook
            String path = cfg.WSR.HandleCustomAttributes(xnav);

            // 7. Parse Result's URL
            String url = GetURL(xnav, rr.Confidence);

            // 8. Parse Result's Dication
            url = HandleWildcard(rr, url);
            if (url == null)
            {
                return;
            }

            // 9. Send the request
            HandleRequest(url, path);
        }