Grammar.SpeechRecognized Ereignis

Definition

Wird ausgelöst, wenn eine Spracherkennung die Erkennung mithilfe des Grammar-Objekts ausführt.Raised when a speech recognizer performs recognition using the Grammar object.

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

Beispiele

Das folgende Beispiel zeigt die Verwendung eines Ereignis Handlers für das SpeechRecognized-Ereignis des Grammar-Objekts.The following example shows the use of an event handler for the Grammar object's SpeechRecognized event. Die Erkennungsergebnisse werden an die Konsoleausgegeben.It outputs the recognition results to the console.

public partial class Form1 : Form  
{  
  SpeechRecognitionEngine sre;  
  
  public Form1()  
  {  
  InitializeComponent();  
  
  // Create an in-process speech recognizer.  
  sre = new SpeechRecognitionEngine();  
  
  // Configure input to the speech recognizer.  
  sre.SetInputToDefaultAudioDevice();  
  
  // Create a simple grammar and load it.  
  Grammar testGrammar = new Grammar(new GrammarBuilder("testing"));  
  sre.LoadGrammarAsync(testGrammar);  
  
  // Add a handler for the grammar's speech recognized event.  
  testGrammar.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(testGrammar_SpeechRecognized);  
  
  // Start asynchronous speech recognition.  
  sre.RecognizeAsync();  
  }  
  
  // Handle the grammar's SpeechRecognized event, output the recognized text.  
  void testGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
  {  
    Console.WriteLine("Recognized text: " + e.Result.Text);  
  }  
}  

Hinweise

Die Spracherkennung löst auch ein SpeechRecognized-Ereignis aus, wenn die Eingabe erkannt wird.The speech recognizer also raises a SpeechRecognized event when it recognizes input. Das SpeechRecognized-Ereignis des Grammar-Objekts wird vor dem SpeechRecognized-Ereignis der Spracherkennung ausgelöst.The Grammar object's SpeechRecognized event is raised prior to the speech recognizer's SpeechRecognized event . Weitere Informationen finden Sie in den Ereignissen SpeechRecognizer.SpeechRecognized, SpeechRecognitionEngine.SpeechRecognized und RecognizeCompleted.For more information, see the SpeechRecognizer.SpeechRecognized, SpeechRecognitionEngine.SpeechRecognized, and RecognizeCompleted events.

Alle für eine bestimmte Grammatik spezifischen Aufgaben sollten immer von Handlern für das SpeechRecognized-Ereignis des Grammar-Objekts behandelt werden.Any tasks specific to a particular grammar should always be handled by handlers for the Grammar object's SpeechRecognized event.

Gilt für:

Siehe auch