RecognizerUpdateReachedEventArgs Klasse

Definition

Gibt Daten von einem RecognizerUpdateReached oder von einem RecognizerUpdateReached-Ereignis zurück.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
Vererbung
RecognizerUpdateReachedEventArgs

Beispiele

Das folgende Beispiel zeigt eine Konsolenanwendung, die Objekte lädt und Grammar entlädt.The following example shows a console application that loads and unloads Grammar objects. Die Anwendung verwendet die RequestRecognizerUpdate -Methode, um die sprach Erkennungs-Engine anzufordern, damit Sie ein Update empfangen kann.The application uses the RequestRecognizerUpdate method to request the speech recognition engine to pause so it can receive an update. Die Anwendung lädt oder entlädt ein Grammar -Objekt.The application then loads or unloads a Grammar object.

Bei jedem Update schreibt ein Handler für SpeechRecognitionEngine.RecognizerUpdateReached das Ereignis den Namen und den Status der aktuell geladenen Grammar Objekte in die Konsole.At each update, a handler for SpeechRecognitionEngine.RecognizerUpdateReached event writes the name and status of the currently loaded Grammar objects to the console. Wenn Grammatiken geladen und entladen werden, erkennt die Anwendung zuerst die Namen von Farm-animals, dann die Namen der Farm-und die Namen der Früchte und dann nur die Namen der Früchte.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");  
    }  
  }  
}  
  

Hinweise

RecognizerUpdateReachedEreignisse bieten einen Mechanismus zum Anhalten einer Spracherkennungs-Engine, um atomarische und synchrone Änderungen wie das Laden und Entladen von Grammatiken anzuwenden.RecognizerUpdateReached events provide a mechanism for pausing a speech recognition engine to apply atomic and synchronous modifications, such as loading and unloading grammars.

Wenn Ihre Anwendung eine SpeechRecognitionEngine -Instanz zum Verwalten der Erkennung verwendet, kann Sie eine SpeechRecognitionEngine.RequestRecognizerUpdate der-Methoden verwenden, um anzufordern, dass die Engine angehalten wird, um ein Update zu erhalten.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. Die SpeechRecognitionEngine -Instanz löst SpeechRecognitionEngine.RecognizerUpdateReached ein-Ereignis aus, wenn Sie für das Update bereit ist.The SpeechRecognitionEngine instance raises a SpeechRecognitionEngine.RecognizerUpdateReached event when it is ready for the update.

Wenn eine SpeechRecognitionEngine -Instanz angehalten ist, können Sie Objekte laden, entladen, aktivieren und Grammar deaktivieren sowie Werte für die BabbleTimeoutEigenschaften, InitialSilenceTimeoutund EndSilenceTimeout ändern.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.

Wenn Ihre Anwendung eine SpeechRecognizer -Instanz zum Verwalten der Erkennung verwendet, kann Sie eine SpeechRecognizer.RequestRecognizerUpdate der-Methoden verwenden, um anzufordern, dass die Engine angehalten wird, um ein Update zu erhalten.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. Die SpeechRecognizer -Instanz löst SpeechRecognizer.RecognizerUpdateReached ein-Ereignis aus, wenn Sie für das Update bereit ist.The SpeechRecognizer instance raises a SpeechRecognizer.RecognizerUpdateReached event when it is ready for the update.

Wenn eine SpeechRecognizer -Instanz angehalten ist, können Sie Objekte laden, entladen, aktivieren und Grammar deaktivieren.While a SpeechRecognizer instance is paused, you can load, unload, enable, and disable Grammar objects.

Bei der SpeechRecognitionEngine.RecognizerUpdateReached Behandlung SpeechRecognizer.RecognizerUpdateReached von-und-Ereignissen wird eine Erkennungs-Engine angehalten, bis der Ereignishandler zurückgibt.When handling SpeechRecognitionEngine.RecognizerUpdateReached and SpeechRecognizer.RecognizerUpdateReached events, a recognition engine pauses until the event handler returns.

RecognizerUpdateReachedEventArgs wird von EventArgs abgeleitet.RecognizerUpdateReachedEventArgs derives from EventArgs.

Eigenschaften

AudioPosition

Ruft die dem Ereignis zugeordnete Audioposition ab.Gets the audio position associated with the event.

UserToken

Ruft das UserToken ab, das dem System übergeben wird, wenn eine Anwendung RequestRecognizerUpdate oder RequestRecognizerUpdate aufruft.Gets the UserToken passed to the system when an application calls RequestRecognizerUpdate or RequestRecognizerUpdate.

Methoden

Equals(Object)

Ermittelt, ob das angegebene Objekt und das aktuelle Objekt gleich sind.Determines whether the specified object is equal to the current object.

(Geerbt von Object)
GetHashCode()

Dient als die Standard-HashfunktionServes as the default hash function.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

(Geerbt von Object)

Gilt für:

Siehe auch