Exemple #1
0
 //语音识别
 private void btnSpeechRecognition1_Click(object sender, EventArgs e)
 {
     System.Speech.Recognition.RecognitionResult result = recognizer.Recognize();
     // Console.WriteLine(result.Text);
     //启动异步,连续语音识别。
     //recognizer.RecognizeAsync(RecognizeMode.Multiple);
 }
Exemple #2
0
        private static object TryExecuteOnRecognition(Grammar grammar, RecognitionResult result, string rootRule)
        {
            object result2 = result.Semantics.Value;

            if (grammar != null && grammar._scripts != null)
            {
                ScriptRef[] scripts = grammar._scripts;
                foreach (ScriptRef scriptRef in scripts)
                {
                    if (!(rootRule == scriptRef._rule) || scriptRef._method != RuleMethodScript.onRecognition)
                    {
                        continue;
                    }
                    object[] parameters = new object[1]
                    {
                        result
                    };
                    if (grammar._proxy != null)
                    {
                        Exception exceptionThrown;
                        result2 = grammar._proxy.OnRecognition(scriptRef._sMethod, parameters, out exceptionThrown);
                        if (exceptionThrown != null)
                        {
                            throw exceptionThrown;
                        }
                    }
                    else
                    {
                        Type       type   = grammar.GetType();
                        MethodInfo method = type.GetMethod(scriptRef._sMethod, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        result2 = method.Invoke(grammar, parameters);
                    }
                }
            }
            return(result2);
        }
Exemple #3
0
 public static bool SendTextFeedback(RecognitionResult result, string feedback, bool isSuccessfulAction)
 {
     Helpers.ThrowIfNull(result, "result");
     Helpers.ThrowIfEmptyOrNull(feedback, "feedback");
     return(result.SetTextFeedback(feedback, isSuccessfulAction));
 }
Exemple #4
0
 internal EmulateRecognizeCompletedEventArgs(RecognitionResult result, Exception error, bool cancelled, object userState)
     : base(error, cancelled, userState)
 {
     _result = result;
 }