RecognizerUpdateReachedEventArgs RecognizerUpdateReachedEventArgs RecognizerUpdateReachedEventArgs RecognizerUpdateReachedEventArgs Class

定義

RecognizerUpdateReached または RecognizerUpdateReached イベントからのデータを返します。Returns data from a RecognizerUpdateReached or a RecognizerUpdateReached event.

public ref class RecognizerUpdateReachedEventArgs : EventArgs
public class RecognizerUpdateReachedEventArgs : EventArgs
type RecognizerUpdateReachedEventArgs = class
    inherit EventArgs
Public Class RecognizerUpdateReachedEventArgs
Inherits EventArgs
継承
RecognizerUpdateReachedEventArgsRecognizerUpdateReachedEventArgsRecognizerUpdateReachedEventArgsRecognizerUpdateReachedEventArgs

次の例では、コンソール アプリケーションをロードおよびアンロードGrammarオブジェクト。The following example shows a console application that loads and unloads Grammar objects. アプリケーションを使用して、RequestRecognizerUpdate音声認識エンジンの更新プログラムを受信できるようにを一時停止を要求するメソッド。The application uses the RequestRecognizerUpdate method to request the speech recognition engine to pause so it can receive an update. アプリケーション、ロードまたはアンロード、Grammarオブジェクト。The application then loads or unloads a Grammar object.

各更新プログラムのハンドラーでSpeechRecognitionEngine.RecognizerUpdateReachedイベントの名前と読み込まれた現在の状態の書き込みGrammarコンソールへのオブジェクト。At each update, a handler for SpeechRecognitionEngine.RecognizerUpdateReached event writes the name and status of the currently loaded Grammar objects to the console. 文法が読み込まれ、アンロード、として、アプリケーションは、ファームの動物の名前、ファームの動物の名前と、果物の名前、果物の名前のみに最初に認識します。As grammars are loaded and unloaded, the application first recognizes the names of farm animals, then the names of farm animals and the names of fruits, then only the names of fruits.

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 イベントは、読み込みと文法をアンロードなどのアトミックと同期の変更を適用する音声認識エンジンを一時停止するためのメカニズムを提供します。RecognizerUpdateReached events provide a mechanism for pausing a speech recognition engine to apply atomic and synchronous modifications, such as loading and unloading grammars.

アプリケーションが使用されている場合、SpeechRecognitionEngine認識機能を管理するインスタンスのいずれかを使用できる、SpeechRecognitionEngine.RequestRecognizerUpdate更新プログラムを受信する、エンジンが一時停止を要求するメソッド。If your application is using a SpeechRecognitionEngine instance to manage recognition, it can use one of the SpeechRecognitionEngine.RequestRecognizerUpdate methods to request that the engine pauses to receive an update. SpeechRecognitionEngineインスタンスが発生、SpeechRecognitionEngine.RecognizerUpdateReached更新の準備ができたときにイベント。The SpeechRecognitionEngine instance raises a SpeechRecognitionEngine.RecognizerUpdateReached event when it is ready for the update.

中に、SpeechRecognitionEngineインスタンスが一時停止、読み込み、アンロード、有効化、および無効にするGrammarオブジェクトし、の値の変更、 BabbleTimeoutInitialSilenceTimeout、およびEndSilenceTimeoutプロパティ。While a SpeechRecognitionEngine instance is paused, you can load, unload, enable, and disable Grammar objects, and modify values for the BabbleTimeout, InitialSilenceTimeout, and EndSilenceTimeout properties.

アプリケーションが使用されている場合、SpeechRecognizer認識機能を管理するインスタンスのいずれかを使用できる、SpeechRecognizer.RequestRecognizerUpdate更新プログラムを受信する、エンジンが一時停止を要求するメソッド。If your application is using a SpeechRecognizer instance to manage recognition, it can use one of the SpeechRecognizer.RequestRecognizerUpdate methods to request that the engine pauses to receive an update. SpeechRecognizerインスタンスが発生、SpeechRecognizer.RecognizerUpdateReached更新の準備ができたときにイベント。The SpeechRecognizer instance raises a SpeechRecognizer.RecognizerUpdateReached event when it is ready for the update.

中に、SpeechRecognizerインスタンスが一時停止、読み込み、アンロード、有効化、および無効にするGrammarオブジェクト。While a SpeechRecognizer instance is paused, you can load, unload, enable, and disable Grammar objects.

処理するときにSpeechRecognitionEngine.RecognizerUpdateReachedSpeechRecognizer.RecognizerUpdateReachedイベント、イベント ハンドラーを返すまで、認識エンジンに一時停止します。When handling SpeechRecognitionEngine.RecognizerUpdateReached and SpeechRecognizer.RecognizerUpdateReached events, a recognition engine pauses until the event handler returns.

RecognizerUpdateReachedEventArgs は、EventArgs から派生します。RecognizerUpdateReachedEventArgs derives from EventArgs.

プロパティ

AudioPosition AudioPosition AudioPosition AudioPosition

イベントに関連付けられているオーディオの位置を取得します。Gets the audio position associated with the event.

UserToken UserToken UserToken UserToken

アプリケーションが RequestRecognizerUpdate または RequestRecognizerUpdate を呼び出すときにシステムに渡される UserToken を取得します。Gets the UserToken passed to the system when an application calls RequestRecognizerUpdate or RequestRecognizerUpdate.

メソッド

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

適用対象

こちらもご覧ください