Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

SpeechRecognitionEngine.InstalledRecognizers Method

Returns information for all of the installed speech recognizers on the current system.

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

Syntax

'Declaration
Public Shared Function InstalledRecognizers As ReadOnlyCollection(Of RecognizerInfo)
'Usage
Dim returnValue As ReadOnlyCollection(Of RecognizerInfo)

returnValue = SpeechRecognitionEngine.InstalledRecognizers()
public static ReadOnlyCollection<RecognizerInfo> InstalledRecognizers()

Return Value

Type: System.Collections.ObjectModel.ReadOnlyCollection<RecognizerInfo>
A read-only collection of the RecognizerInfo objects that describe the installed recognizers.

Remarks

To get information about the current recognizer, use the RecognizerInfo property.

A recognizer is an installed Runtime Language. A Runtime Language includes the language model, acoustic model, and other data necessary to provision a speech engine to perform speech recognition in a particular language. The Microsoft Speech Platform Runtime 11 and Microsoft Speech Platform SDK 11 do not include Runtime Languages for speech recognition. You must download a Runtime Language for each language in which you want to perform speech recognition.

The Runtime Languages are different for each version of the Speech Platform Runtime. You must download the Runtime Language version that matches the version of the Speech Platform Runtime that you have installed. The Runtime Languages for the Speech Platform SDK 11 are redistributable and are different than the languages that ship with Windows Vista or Windows 7. Use the following link to download Runtime Languages for version 11 of the Speech Platform Runtime:

See Language Support for a list of languages for which you can download Runtime Languages.

Examples

The following example shows part of a console application that demonstrates basic speech recognition. The example uses the collection returned by the InstalledRecognizers() method to find a speech recognizer that supports the English language.

using System;
using Microsoft.Speech.Recognition;

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

      // Select a speech recognizer that supports English.
      RecognizerInfo info = null;
      foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
      {
        if (ri.Culture.TwoLetterISOLanguageName.Equals("en"))
        {
          info = ri;
          break;
        }
      }
      if (info == null) return;

      // Create the selected recognizer.
      using (SpeechRecognitionEngine recognizer =
        new SpeechRecognitionEngine(info))
      {

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

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

        // Configure input to the speech recognizer.
        recognizer.SetInputToDefaultAudioDevice();

        // Start asynchronous, continuous speech recognition.
        recognizer.RecognizeAsync(RecognizeMode.Multiple);

        // Keep the console window open.
        while (true)
        {
          Console.ReadLine();
        }
      }
    }

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

See Also

Reference

SpeechRecognitionEngine Class

SpeechRecognitionEngine Members

Microsoft.Speech.Recognition Namespace