RecognizerUpdateReachedEventArgs 클래스

정의

또는 이벤트에서 데이터를 RecognizerUpdateReached 반환합니다 RecognizerUpdateReached .

public ref class RecognizerUpdateReachedEventArgs : EventArgs
public class RecognizerUpdateReachedEventArgs : EventArgs
type RecognizerUpdateReachedEventArgs = class
    inherit EventArgs
Public Class RecognizerUpdateReachedEventArgs
Inherits EventArgs
상속
RecognizerUpdateReachedEventArgs

예제

다음 예제에서는 개체를 로드하고 언로드하는 콘솔 애플리케이션을 보여 줍니다 Grammar . 애플리케이션은 이 메서드를 RequestRecognizerUpdate 사용하여 음성 인식 엔진이 업데이트를 받을 수 있도록 일시 중지하도록 요청합니다. 그런 다음 애플리케이션은 개체를 로드하거나 언로드합니다 Grammar .

각 업데이트에서 이벤트 처리기는 SpeechRecognitionEngine.RecognizerUpdateReached 현재 로드된 Grammar 개체의 이름과 상태를 콘솔에 씁니다. 문법이 로드되고 언로드되면 애플리케이션은 먼저 농장 동물의 이름, 농장 동물의 이름 및 과일 이름, 과일 이름만 인식합니다.

using System;
using System.Speech.Recognition;
using System.Collections.Generic;
using System.Threading;

namespace SampleRecognition
{
  class Program
  {
    private static SpeechRecognitionEngine recognizer;
    public static void Main(string[] args)
    {

      // Initialize an in-process speech recognition engine and configure its input.
      using (recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
      {
        recognizer.SetInputToDefaultAudioDevice();

        // Create the first grammar - Farm.
        Choices animals = new Choices(new string[] { "cow", "pig", "goat" });
        GrammarBuilder farm = new GrammarBuilder(animals);
        Grammar farmAnimals = new Grammar(farm);
        farmAnimals.Name = "Farm";

        // Create the second grammar - Fruit.
        Choices fruit = new Choices(new string[] { "apples", "peaches", "oranges" });
        GrammarBuilder favorite = new GrammarBuilder(fruit);
        Grammar favoriteFruit = new Grammar(favorite);
        favoriteFruit.Name = "Fruit";

        // Attach event handlers.
        recognizer.SpeechRecognized +=
          new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
        recognizer.RecognizerUpdateReached +=
          new EventHandler<RecognizerUpdateReachedEventArgs>(recognizer_RecognizerUpdateReached);
        recognizer.SpeechRecognitionRejected +=
          new EventHandler<SpeechRecognitionRejectedEventArgs>(recognizer_SpeechRecognitionRejected);

        // Load the Farm grammar.
        recognizer.LoadGrammar(farmAnimals);

        // Start asynchronous, continuous recognition.
        recognizer.RecognizeAsync(RecognizeMode.Multiple);
        Console.WriteLine("Starting asynchronous, continuous recognition");
        Console.WriteLine("  Farm grammar is loaded and enabled.");

        // Pause to recognize farm animals.
        Thread.Sleep(7000);
        Console.WriteLine();

        // Request an update and load the Fruit grammar.
        recognizer.RequestRecognizerUpdate();
        recognizer.LoadGrammarAsync(favoriteFruit);
        Thread.Sleep(7000);

        // Request an update and unload the Farm grammar.
        recognizer.RequestRecognizerUpdate();
        recognizer.UnloadGrammar(farmAnimals);
        Thread.Sleep(7000);
      }

      // Keep the console window open.
      Console.WriteLine();
      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }

    // At the update, get the names and enabled status of the currently loaded grammars.
    public static void recognizer_RecognizerUpdateReached(
      object sender, RecognizerUpdateReachedEventArgs e)
    {
      Console.WriteLine();
      Console.WriteLine("Update reached:");
      Thread.Sleep(1000);

      string qualifier;
      List<Grammar> grammars = new List<Grammar>(recognizer.Grammars);
      foreach (Grammar g in grammars)
      {
        qualifier = (g.Enabled) ? "enabled" : "disabled";
        Console.WriteLine("  {0} grammar is loaded and {1}.",
        g.Name, qualifier);
      }
    }

    // Write the text of the recognized phrase to the console.
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      Console.WriteLine("    Speech recognized: " + e.Result.Text);
    }

    // Write a message to the console when recognition fails.
    static void recognizer_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
    {
      Console.WriteLine("    Recognition attempt failed");
    }
  }
}

설명

RecognizerUpdateReached 이벤트는 문법 로드 및 언로드와 같은 원자성 및 동기 수정을 적용하기 위해 음성 인식 엔진을 일시 중지하는 메커니즘을 제공합니다.

애플리케이션이 인스턴스를 SpeechRecognitionEngine 사용하여 인식을 관리하는 경우 메서드 중 SpeechRecognitionEngine.RequestRecognizerUpdate 하나를 사용하여 엔진이 업데이트를 받기 위해 일시 중지하도록 요청할 수 있습니다. 인스턴스는 SpeechRecognitionEngine 업데이트할 준비가 되면 이벤트를 발생 SpeechRecognitionEngine.RecognizerUpdateReached 합니다.

인스턴스가 SpeechRecognitionEngine 일시 중지되는 동안 개체를 로드, 언로드, 사용 및 사용하지 않도록 설정하고 Grammar , 및 BabbleTimeoutInitialSilenceTimeout 속성에 EndSilenceTimeout대한 값을 수정할 수 있습니다.

애플리케이션이 인스턴스를 SpeechRecognizer 사용하여 인식을 관리하는 경우 메서드 중 SpeechRecognizer.RequestRecognizerUpdate 하나를 사용하여 엔진이 업데이트를 받기 위해 일시 중지하도록 요청할 수 있습니다. 인스턴스는 SpeechRecognizer 업데이트할 준비가 되면 이벤트를 발생 SpeechRecognizer.RecognizerUpdateReached 합니다.

인스턴스가 SpeechRecognizer 일시 중지된 동안 개체를 로드, 언로드, 사용 및 사용하지 않도록 설정할 Grammar 수 있습니다.

이벤트 처리 및 SpeechRecognitionEngine.RecognizerUpdateReached 이벤트를 처리할 SpeechRecognizer.RecognizerUpdateReached 때 인식 엔진은 이벤트 처리기가 반환될 때까지 일시 중지됩니다.

RecognizerUpdateReachedEventArgs 에서 파생됩니다 EventArgs.

속성

Name Description
AudioPosition

이벤트와 연결된 오디오 위치를 가져옵니다.

UserToken

애플리케이션이 UserToken 호출 RequestRecognizerUpdate 하거나 RequestRecognizerUpdate호출할 때 시스템에 전달되는 값을 가져옵니다.

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보