Exemplo n.º 1
0
        protected XPathNavigator HandleSpeech(RecognitionResult rr)
        {
            XPathNavigator xnav = rr.ConstructSmlFromSemantics().CreateNavigator();

            double confidence = GetConfidence(xnav);

            // Normal check
            if (rr.Grammar.Name != "Dyn")
            {
                if (rr.Confidence < confidence)
                {
                    cfg.logWarning("ENGINE - " + Name, "REJECTED Speech: " + rr.Confidence + " < " + confidence + " Device: " + " Text: " + rr.Text);
                    return(null);
                }

                if (rr.Words[0].Confidence < cfg.trigger)
                {
                    cfg.logWarning("ENGINE - " + Name, "REJECTED Trigger: " + rr.Words[0].Confidence + " Text: " + rr.Words[0].Text);
                    return(null);
                }
            }

            // Dynamic check
            else
            {
                confidence = confidence - 0.2;
                cfg.logInfo("ENGINE - " + Name + " - DYN", "Dynamic Grammar");
                if (rr.Confidence < (confidence))
                {
                    cfg.logWarning("ENGINE - " + Name + " - DYN", "REJECTED Speech: " + rr.Confidence + " < " + confidence + " Device: " + " Text: " + rr.Text);
                    return(null);
                }
            }

            cfg.logWarning("ENGINE - " + Name, "RECOGNIZED Speech: " + rr.Confidence + " (" + confidence + ") / " + rr.Words[0].Confidence + " (" + rr.Words[0].Text + ")" + " Device: " + " Text: " + rr.Text);
            cfg.logDebug("ENGINE - " + Name, xnav.OuterXml);

            if (cfg.DEBUG)
            {
                WSRSpeechManager.GetInstance().DumpAudio(rr);
            }

            return(xnav);
        }