SpeechRecognizer.EmulateRecognizeCompleted 이벤트

정의

공유 인식기 에뮬레이트된 입력에 대 한 비동기 인식 작업을 종료 할 때 발생 합니다.

public:
 event EventHandler<System::Speech::Recognition::EmulateRecognizeCompletedEventArgs ^> ^ EmulateRecognizeCompleted;
public event EventHandler<System.Speech.Recognition.EmulateRecognizeCompletedEventArgs> EmulateRecognizeCompleted;
member this.EmulateRecognizeCompleted : EventHandler<System.Speech.Recognition.EmulateRecognizeCompletedEventArgs> 
Public Event EmulateRecognizeCompleted As EventHandler(Of EmulateRecognizeCompletedEventArgs) 
Public Custom Event EmulateRecognizeCompleted As EventHandler(Of EmulateRecognizeCompletedEventArgs) 

이벤트 유형

예제

다음 예제는 콘솔 애플리케이션을 음성 인식 문법을 로드 및 비동기 에뮬레이트된 입력, 연결 된 인식 결과 및 음성 인식기에 의해 발생 하는 연결 된 이벤트를 보여 줍니다. Windows 음성 인식을 실행 하지 않는 경우 다음이 애플리케이션을 시작 Windows 음성 인식 됩니다도 시작 됩니다. Windows 음성 인식이 경우 합니다 중지 모드에서는 다음 EmulateRecognizeAsync 항상 null을 반환 합니다.

using System;  
using System.Speech.Recognition;  
using System.Threading;  

namespace SharedRecognizer  
{  
  class Program  
  {  
    // Indicate whether the asynchronous emulate recognition  
    // operation has completed.  
    static bool completed;  

    static void Main(string[] args)  
    {  

      // Initialize an instance of the shared recognizer.  
      using (SpeechRecognizer recognizer = new SpeechRecognizer())  
      {  
        // Create and load a sample grammar.  
        Grammar testGrammar =  
          new Grammar(new GrammarBuilder("testing testing"));  
        testGrammar.Name = "Test Grammar";  
        recognizer.LoadGrammar(testGrammar);  

        // Attach event handlers for recognition events.  
        recognizer.SpeechRecognized +=   
          new EventHandler<SpeechRecognizedEventArgs>(SpeechRecognizedHandler);  
        recognizer.EmulateRecognizeCompleted +=   
          new EventHandler<EmulateRecognizeCompletedEventArgs>(  
            EmulateRecognizeCompletedHandler);  

        completed = false;  

        // This EmulateRecognizeAsync call generates a SpeechRecognized event.  
        recognizer.EmulateRecognizeAsync("testing testing");  

        // Wait for the asynchronous operation to complete.  
        while (!completed)  
        {  
          Thread.Sleep(333);  
        }  

        completed = false;  

        // This EmulateRecognizeAsync call does not match the grammar  
        // or generate a SpeechRecognized event.  
        recognizer.EmulateRecognizeAsync("testing one two three");  

        // Wait for the asynchronous operation to complete.  
        while (!completed)  
        {  
          Thread.Sleep(333);  
        }  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  

    // Handle the SpeechRecognized event.  
    static void SpeechRecognizedHandler(  
      object sender, SpeechRecognizedEventArgs e)  
    {  
      if (e.Result != null)  
      {  
        Console.WriteLine("Recognition result = {0}",  
          e.Result.Text ?? "<no text>");  
      }  
      else  
      {  
        Console.WriteLine("No recognition result");  
      }  
    }  

    // Handle the EmulateRecognizeCompleted event.  
    static void EmulateRecognizeCompletedHandler(  
      object sender, EmulateRecognizeCompletedEventArgs e)  
    {  
      if (e.Result == null)  
      {  
        Console.WriteLine("No result generated.");  
      }  

      // Indicate the asynchronous operation is complete.  
      completed = true;  
    }  
  }  
}  

설명

EmulateRecognizeAsync 메서드는 비동기 인식 작업을 시작 합니다. 인식기가 발생 합니다 EmulateRecognizeCompleted 비동기 작업을 완료 하는 경우에 이벤트입니다.

비동기 인식 작업을 발생 시킬 수는 SpeechDetected, SpeechHypothesizedSpeechRecognitionRejected, 및 SpeechRecognized 이벤트입니다. EmulateRecognizeCompleted 이벤트는 마지막 이러한 이벤트 인식기를 지정된 된 작업에 대 한 발생 시킵니다.

에 대 한 대리자를 만들 때는 EmulateRecognizeCompleted 이벤트에 이벤트를 처리 하는 메서드를 식별 합니다. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다. 대리자를 제거하지 않는 경우 이벤트가 발생할 때마다 이벤트 처리기가 호출됩니다. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 및 대리자합니다.

적용 대상

추가 정보