SpeechRecognitionEngine Constructor (String)


Initializes a new instance of the SpeechRecognitionEngine class with a string parameter that specifies the name of the recognizer to use.

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

public SpeechRecognitionEngine(
	string recognizerId


Type: System.String

The token name of the speech recognizer to use.

Exception Condition

No speech recognizer with that token name is installed, or recognizerId is the empty string ("").


recognizerId is null.

The token name of the recognizer is the value of the Id property of the RecognizerInfo object returned by the RecognizerInfo property of the recognizer. To get a collection of all the installed recognizers, use the static InstalledRecognizers method.

Before the speech recognizer can begin recognition, you must load at least one speech recognition grammar and configure the input for the recognizer.

To load a grammar, call the LoadGrammar or LoadGrammarAsync method.

To configure the audio input, use one of the following methods:

The following example shows part of a console application that demonstrates basic speech recognition, and creates an instance of the Speech Recognizer 8.0 for Windows (English - US).

using System;
using System.Speech.Recognition;

namespace SpeechRecognitionApp
  class Program
    static void Main(string[] args)

      // Create an instance of the Microsoft Speech Recognizer 8.0 for
      // Windows (English - US).
      using (SpeechRecognitionEngine recognizer =
        new SpeechRecognitionEngine("MS-1033-80-DESK"))

        // Create and load a dictation grammar.
        recognizer.LoadGrammar(new DictationGrammar());

        // Add a handler for the speech recognized event.
        recognizer.SpeechRecognized += new EventHandler(recognizer_SpeechRecognized);

        // Configure input to the speech recognizer.

        // Start asynchronous, continuous speech recognition.

        // Keep the console window open.
        while (true)

    // Handle the SpeechRecognized event.
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
      Console.WriteLine("Recognized text: " + e.Result.Text);

.NET Framework
Available since 3.0
Return to top