Partager via


SpeechRecognitionEngine.InstalledRecognizers Méthode

Définition

Retourne les informations sur tous les modules de reconnaissance vocale installés sur le système actuel.

public:
 static System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::RecognizerInfo ^> ^ InstalledRecognizers();
public static System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.RecognizerInfo> InstalledRecognizers ();
static member InstalledRecognizers : unit -> System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.RecognizerInfo>
Public Shared Function InstalledRecognizers () As ReadOnlyCollection(Of RecognizerInfo)

Retours

Collection d'objets RecognizerInfo en lecture seule qui décrivent les modules de reconnaissance installés.

Exemples

L’exemple suivant montre une partie d’une application console qui illustre la reconnaissance vocale de base. L’exemple utilise la collection retournée par la InstalledRecognizers méthode pour rechercher un module de reconnaissance vocale qui prend en charge la langue anglaise.

using System;  
using System.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);  
    }  
  }  
}  

Remarques

Pour obtenir des informations sur le module de reconnaissance actuel, utilisez la RecognizerInfo propriété .

S’applique à

Voir aussi