A common base class for both keyword recognizer and grammar recognizer.

Inheritance: IDisposable
Ejemplo n.º 1
0
        public KeywordRecognizer(string[] keywords, ConfidenceLevel minimumConfidence)
        {
            bool flag = keywords == null;

            if (flag)
            {
                throw new ArgumentNullException("keywords");
            }
            bool flag2 = keywords.Length == 0;

            if (flag2)
            {
                throw new ArgumentException("At least one keyword must be specified.", "keywords");
            }
            int num = keywords.Length;

            for (int i = 0; i < num; i++)
            {
                bool flag3 = keywords[i] == null;
                if (flag3)
                {
                    throw new ArgumentNullException(string.Format("Keyword at index {0} is null.", i));
                }
            }
            this.Keywords     = keywords;
            this.m_Recognizer = PhraseRecognizer.CreateFromKeywords(this, keywords, minimumConfidence);
        }
Ejemplo n.º 2
0
 public void Stop()
 {
     if (!(this.m_Recognizer == IntPtr.Zero))
     {
         PhraseRecognizer.Stop_Internal(this.m_Recognizer);
     }
 }
Ejemplo n.º 3
0
        protected IntPtr CreateFromGrammarFile(string grammarFilePath, ConfidenceLevel minimumConfidence)
        {
            IntPtr result;

            PhraseRecognizer.INTERNAL_CALL_CreateFromGrammarFile(this, grammarFilePath, minimumConfidence, out result);
            return(result);
        }
Ejemplo n.º 4
0
        protected IntPtr CreateFromKeywords(string[] keywords, ConfidenceLevel minimumConfidence)
        {
            IntPtr result;

            PhraseRecognizer.INTERNAL_CALL_CreateFromKeywords(this, keywords, minimumConfidence, out result);
            return(result);
        }
Ejemplo n.º 5
0
 public void Start()
 {
     if (this.m_Recognizer == IntPtr.Zero)
     {
         return;
     }
     PhraseRecognizer.Start_Internal(this.m_Recognizer);
 }
Ejemplo n.º 6
0
 public void Dispose()
 {
     if (this.m_Recognizer != IntPtr.Zero)
     {
         PhraseRecognizer.Destroy(this.m_Recognizer);
         this.m_Recognizer = IntPtr.Zero;
     }
     GC.SuppressFinalize(this);
 }
        public void Stop()
        {
            bool flag = this.m_Recognizer == IntPtr.Zero;

            if (!flag)
            {
                PhraseRecognizer.Stop_Internal(this.m_Recognizer);
            }
        }
 static public int Start(IntPtr l)
 {
     try {
         UnityEngine.Windows.Speech.PhraseRecognizer self = (UnityEngine.Windows.Speech.PhraseRecognizer)checkSelf(l);
         self.Start();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_IsRunning(IntPtr l)
 {
     try {
         UnityEngine.Windows.Speech.PhraseRecognizer self = (UnityEngine.Windows.Speech.PhraseRecognizer)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.IsRunning);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        public GrammarRecognizer(string grammarFilePath, ConfidenceLevel minimumConfidence)
        {
            bool flag = grammarFilePath == null;

            if (flag)
            {
                throw new ArgumentNullException("grammarFilePath");
            }
            bool flag2 = grammarFilePath.Length == 0;

            if (flag2)
            {
                throw new ArgumentException("Grammar file path cannot be empty.");
            }
            this.GrammarFilePath = grammarFilePath;
            this.m_Recognizer    = PhraseRecognizer.CreateFromGrammarFile(this, grammarFilePath, minimumConfidence);
        }
 protected override void Finalize()
 {
     try
     {
         bool flag = this.m_Recognizer != IntPtr.Zero;
         if (flag)
         {
             PhraseRecognizer.DestroyThreaded(this.m_Recognizer);
             this.m_Recognizer = IntPtr.Zero;
             GC.SuppressFinalize(this);
         }
     }
     finally
     {
         base.Finalize();
     }
 }
Ejemplo n.º 12
0
 private static extern void INTERNAL_CALL_CreateFromGrammarFile(PhraseRecognizer self, string grammarFilePath, ConfidenceLevel minimumConfidence, out IntPtr value);
Ejemplo n.º 13
0
 private static extern void INTERNAL_CALL_CreateFromKeywords(PhraseRecognizer self, string[] keywords, ConfidenceLevel minimumConfidence, out IntPtr value);
Ejemplo n.º 14
0
 private static extern void INTERNAL_CALL_CreateFromKeywords(PhraseRecognizer self, string[] keywords, ConfidenceLevel minimumConfidence, out IntPtr value);
Ejemplo n.º 15
0
 private static extern void INTERNAL_CALL_CreateFromGrammarFile(PhraseRecognizer self, string grammarFilePath, ConfidenceLevel minimumConfidence, out IntPtr value);
        void Start()
        {
            if (KeysAndResponses.Length > 0)
            {
                //    // Convert the struct array into a dictionary, with the keywords and the keys and the methods as the values.
                //    // This helps easily link the keyword recognized to the UnityEvent to be invoked.
                responses = KeysAndResponses.ToDictionary(k=>k.Keyword,k=>k);

                secondaryKeywordDictionary=KeyAndTypes.ToDictionary(k=>k.SemanticKeyword,k=>k);

                string filePath = System.IO.Path.Combine(Application.streamingAssetsPath, grammarPath);

                if(System.IO.File.Exists(filePath))
                {

            Debug.Log("Loading grammar path = " + filePath);

                grammarRecognizer = new GrammarRecognizer(filePath); //new KeywordRecognizer(responses.Keys.ToArray());

                grammarRecognizer.OnPhraseRecognized += PhraseRecognizer_OnPhraseRecognized;

                if (RecognizerStart == RecognizerStartBehavior.AutoStart)
                {

                    grammarRecognizer.Start();
                }

                 Debug.Log("Is grammar running = " + grammarRecognizer.IsRunning);
                }
                else
                {
                    Debug.LogWarningFormat("File path for grxml Grammar file not found: {0}", filePath);
                }
            }
            else
            {
                Debug.LogError("Must have at least one keyword and Semantic array specified in the Inspector on " + gameObject.name + ".");
            }
        }