InstalledRecognizers Method

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

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

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

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

Return Value

Type: System.Collections.ObjectModel..::..ReadOnlyCollection<(Of <(<'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.

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.

C# Copy imageCopy Code
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