Partilhar via


Note

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

RecognizerInfo Class

Represents information about a SpeechRecognitionEngine object.

Inheritance Hierarchy

System.Object
  Microsoft.Speech.Recognition.RecognizerInfo

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

Syntax

'Declaration
Public Class RecognizerInfo
'Usage
Dim instance As RecognizerInfo
public class RecognizerInfo

Remarks

SpeechRecognitionEngine.RecognizerInfo provides identifying information for an initialized SpeechRecognitionEngine object.

You can use instances of RecognizerInfo to construct a specific configuration of SpeechRecognitionEngine using the SpeechRecognitionEngine(RecognizerInfo) constructor.

The static method InstalledRecognizers() returns a list of all available SpeechRecognitionEngine configurations as RecognizerInfo instances.

Examples

The example below validates a given CultureInfo and identifier string against the permitted SpeechRecognitionEngine configurations, expressed as a list of RecognizerInfo objects.

If the CultureInfo and identifier string are valid, the example creates a new instance of SpeechRecognitionEngine using the RecognizerInfo instance as an argument.

private SpeechRecognitionEngine SelectRecognizer(CultureInfo requiredCulture, string requiredId) 
{
  // Select based on a specific recognizer configuration:
  SpeechRecognitionEngine speechRecognitionEngine = null;
  foreach (RecognizerInfo config in SpeechRecognitionEngine.InstalledRecognizers()) 
  {
    if (config.Culture.Equals(requiredCulture) && config.Id== requiredId) 
    {
      speechRecognitionEngine = new SpeechRecognitionEngine(config);
      break;
    }
  }
  return speechRecognitionEngine;
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

RecognizerInfo Members

Microsoft.Speech.Recognition Namespace

SpeechRecognitionEngine