예제 #1
0
 // 识别过程中的中间结果
 private void Recognizer_IntermediateResultReceived(object sender, IntentRecognitionResultEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Result.Text))
     {
         Log("中间结果: " + e.Result.Text);
     }
 }
예제 #2
0
        // 获得音频分析后的文本内容
        private void Recognizer_FinalResultReceived(object sender, IntentRecognitionResultEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Result.IntentId))
            {
                Log("最终语音转文本结果: " + e.Result.Text);

                string intent = e.Result.IntentId;
                Log("意图: " + intent + "\r\n");

                // 按照意图控制灯
                if (!string.IsNullOrEmpty(intent))
                {
                    if (intent.Equals("TurnOn", StringComparison.OrdinalIgnoreCase))
                    {
                        OpenLight();
                    }
                    else if (intent.Equals("TurnOff", StringComparison.OrdinalIgnoreCase))
                    {
                        CloseLight();
                    }
                }
            }
        }