SpeechRecognitionEngine.InstalledRecognizers SpeechRecognitionEngine.InstalledRecognizers SpeechRecognitionEngine.InstalledRecognizers SpeechRecognitionEngine.InstalledRecognizers Method

定義

現在のシステムにインストールされているすべての音声認識に関する情報を返します。Returns information for all of the installed speech recognizers on the current system.

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)

戻り値

インストールされたレコグナイザーを記述する RecognizerInfo オブジェクトの読み取り専用コレクション。A read-only collection of the RecognizerInfo objects that describe the installed recognizers.

次の例では、基本的な音声認識を示すコンソール アプリケーションの一部を示します。The following example shows part of a console application that demonstrates basic speech recognition. 例では、によって返されるコレクションを使用して、InstalledRecognizers英語の言語をサポートする音声認識エンジンを検索するメソッド。The example uses the collection returned by the InstalledRecognizers method to find a speech recognizer that supports the English language.

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);  
    }  
  }  
}  

注釈

現在の認識エンジンに関する情報を取得する、RecognizerInfoプロパティ。To get information about the current recognizer, use the RecognizerInfo property.

適用対象

こちらもご覧ください