Grammar.SpeechRecognized イベント

定義

音声認識エンジンが Grammar オブジェクトを使用して認識を実行するときに発生します。

public:
 event EventHandler<System::Speech::Recognition::SpeechRecognizedEventArgs ^> ^ SpeechRecognized;
public event EventHandler<System.Speech.Recognition.SpeechRecognizedEventArgs> SpeechRecognized;
member this.SpeechRecognized : EventHandler<System.Speech.Recognition.SpeechRecognizedEventArgs> 
Public Event SpeechRecognized As EventHandler(Of SpeechRecognizedEventArgs) 
Public Custom Event SpeechRecognized As EventHandler(Of SpeechRecognizedEventArgs) 

イベントの種類

次の例は、オブジェクトSpeechRecognizedのイベントにイベント ハンドラーを使用する方法をGrammar示しています。 認識結果をコンソールに出力 します

public partial class Form1 : Form  
{  
  SpeechRecognitionEngine sre;  

  public Form1()  
  {  
  InitializeComponent();  

  // Create an in-process speech recognizer.  
  sre = new SpeechRecognitionEngine();  

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

  // Create a simple grammar and load it.  
  Grammar testGrammar = new Grammar(new GrammarBuilder("testing"));  
  sre.LoadGrammarAsync(testGrammar);  

  // Add a handler for the grammar's speech recognized event.  
  testGrammar.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(testGrammar_SpeechRecognized);  

  // Start asynchronous speech recognition.  
  sre.RecognizeAsync();  
  }  

  // Handle the grammar's SpeechRecognized event, output the recognized text.  
  void testGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
  {  
    Console.WriteLine("Recognized text: " + e.Result.Text);  
  }  
}  

注釈

音声認識エンジンは、入力を SpeechRecognized 認識するとイベントも発生します。 Grammarオブジェクトの SpeechRecognized イベントは、音声認識エンジンSpeechRecognizedの イベント の前に発生します。 詳細については、および イベントに SpeechRecognizer.SpeechRecognizedSpeechRecognitionEngine.SpeechRecognizedするページを RecognizeCompleted 参照してください。

特定の文法に固有のタスクは、オブジェクトSpeechRecognizedの イベントのハンドラーによって常にGrammar処理される必要があります。

適用対象

こちらもご覧ください