SpeechRecognizedEventArgs SpeechRecognizedEventArgs SpeechRecognizedEventArgs SpeechRecognizedEventArgs Class

定義

SpeechRecognizedSpeechRecognized、および SpeechRecognized のイベントに情報を提供します。Provides information for the SpeechRecognized, SpeechRecognized, and SpeechRecognized events.

public ref class SpeechRecognizedEventArgs : System::Speech::Recognition::RecognitionEventArgs
[System.Serializable]
public class SpeechRecognizedEventArgs : System.Speech.Recognition.RecognitionEventArgs
type SpeechRecognizedEventArgs = class
    inherit RecognitionEventArgs
Public Class SpeechRecognizedEventArgs
Inherits RecognitionEventArgs
継承
SpeechRecognizedEventArgsSpeechRecognizedEventArgsSpeechRecognizedEventArgsSpeechRecognizedEventArgs
属性

次の例は、音声認識の文法を読み込み、共有認識エンジンに対する音声入力、関連する認識結果、音声認識エンジンによって発生した関連イベントを示すコンソールアプリケーションの一部です。The following example is part of a console application that loads a speech recognition grammar and demonstrates speech input to the shared recognizer, the associated recognition results, and the associated events raised by the speech recognizer. Windows 音声認識が実行されていない場合は、このアプリケーションを起動すると、Windows 音声認識も開始されます。If Windows Speech Recognition is not running, then starting this application will also start Windows Speech Recognition.

"シカゴからマイアミへの飛行を希望する" などの音声入力は、 SpeechRecognizedイベントをトリガーします。Spoken input such as "I want to fly from Chicago to Miami" will trigger a SpeechRecognized event. "ヒューストンからシカゴに移動する" という語句は、イベントをSpeechRecognizedトリガーしません。Speaking the phrase "Fly me from Houston to Chicago " will not trigger a SpeechRecognized event.

この例では、 SpeechRecognizedイベントのハンドラーを使用して、正常に認識された語句と、コンソールに含まれるセマンティクスを表示します。The example uses a handler for the SpeechRecognized event to display successfully recognized phrases and the semantics they contain in the console.

using System;  
using System.Speech.Recognition;  
  
namespace SampleRecognition  
{  
  class Program  
  {  
    static void Main(string[] args)  
  
    // Initialize a shared speech recognition engine.  
    {  
      using (SpeechRecognizer recognizer = new SpeechRecognizer())  
      {  
  
        // Create SemanticResultValue objects that contain cities and airport codes.  
        SemanticResultValue chicago = new SemanticResultValue("Chicago", "ORD");  
        SemanticResultValue boston = new SemanticResultValue("Boston", "BOS");  
        SemanticResultValue miami = new SemanticResultValue("Miami", "MIA");  
        SemanticResultValue dallas = new SemanticResultValue("Dallas", "DFW");  
  
        // Create a Choices object and add the SemanticResultValue objects, using  
        // implicit conversion from SemanticResultValue to GrammarBuilder  
        Choices cities = new Choices();  
        cities.Add(new Choices(new GrammarBuilder[] { chicago, boston, miami, dallas }));  
  
        // Build the phrase and add SemanticResultKeys.  
        GrammarBuilder chooseCities = new GrammarBuilder();  
        chooseCities.Append("I want to fly from");  
        chooseCities.Append(new SemanticResultKey("origin", cities));  
        chooseCities.Append("to");  
        chooseCities.Append(new SemanticResultKey("destination", cities));  
  
        // Build a Grammar object from the GrammarBuilder.  
        Grammar bookFlight = new Grammar(chooseCities);  
        bookFlight.Name = "Book Flight";  
  
        // Add a handler for the LoadGrammarCompleted event.  
        recognizer.LoadGrammarCompleted +=  
          new EventHandler<LoadGrammarCompletedEventArgs>(recognizer_LoadGrammarCompleted);  
  
        // Add a handler for the SpeechRecognized event.  
        recognizer.SpeechRecognized +=   
          new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);  
  
        // Load the grammar object to the recognizer.  
        recognizer.LoadGrammarAsync(bookFlight);  
  
        // Keep the console window open.  
        Console.ReadLine();  
      }  
    }  
  
    // Handle the LoadGrammarCompleted event.  
    static void recognizer_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e)  
    {  
      Console.WriteLine("Grammar loaded: " + e.Grammar.Name);  
      Console.WriteLine();  
    }  
  
    // Handle the SpeechRecognized event.  
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
    {  
      Console.WriteLine("Speech recognized:  " + e.Result.Text);  
      Console.WriteLine();  
      Console.WriteLine("Semantic results:");  
      Console.WriteLine("  The flight origin is " + e.Result.Semantics["origin"].Value);  
      Console.WriteLine("  The flight destination is " + e.Result.Semantics["destination"].Value);  
    }  
  }  
}  
  

注釈

、、 Grammar SpeechRecognized およびSpeechRecognizerの各クラスによってイベントがSpeechRecognitionEngine発生します。A SpeechRecognized event is raised by the Grammar, SpeechRecognizer and SpeechRecognitionEngine classes.

SpeechRecognizedイベントは、認識操作の1つ以上の代替が許容される十分な信頼スコアを持っている場合に生成されます。SpeechRecognized events are generated when one or more of the alternates from a recognition operation have a high enough confidence score to be accepted. 認識された語句に関する詳細情報を取得Resultするには、イベントのハンドラーのプロパティにアクセスします。To obtain detailed information about a recognized phrase, access the Result property in the handler for the event.

SpeechRecognizedEventArgsRecognitionEventArgsクラスから派生します。SpeechRecognizedEventArgs derives from the RecognitionEventArgs class.

メソッド

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)

GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)

ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

プロパティ

Result Result Result Result

音声認識イベントに関連付けられている認識結果データを取得します。Gets the recognition result data associated with the speech recognition event.

(Inherited from RecognitionEventArgs)

適用対象

こちらもご覧ください