Export (0) Print
Expand All

Grammar.SpeechRecognized Event

Raised when a speech recognizer performs recognition using the Grammar object.

Namespace:  System.Speech.Recognition
Assembly:  System.Speech (in System.Speech.dll)

public event EventHandler<SpeechRecognizedEventArgs> SpeechRecognized

The speech recognizer also raises a SpeechRecognized event when it recognizes input. The Grammar object's SpeechRecognized event is raised prior to the speech recognizer's SpeechRecognized event . For more information, see the SpeechRecognizer.SpeechRecognized, SpeechRecognitionEngine.SpeechRecognized, and RecognizeCompleted events.

Any tasks specific to a particular grammar should always be handled by handlers for the Grammar object's SpeechRecognized event.

The following example shows the use of an event handler for the Grammar object's SpeechRecognized event. It outputs the recognition results to the console.

public partial class Form1 : Form
  SpeechRecognitionEngine sre;

  public Form1()

  // Create an in-process speech recognizer.
  sre = new SpeechRecognitionEngine();

  // Configure input to the speech recognizer.

  // Create a simple grammar and load it.
  Grammar testGrammar = new Grammar(new GrammarBuilder("testing"));

  // Add a handler for the grammar's speech recognized event.
  testGrammar.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(testGrammar_SpeechRecognized);

  // Start asynchronous speech recognition.

  // Handle the grammar's SpeechRecognized event, output the recognized text.
  void testGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    Console.WriteLine("Recognized text: " + e.Result.Text);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft