SpeechRecognitionRejectedEventArgs SpeechRecognitionRejectedEventArgs SpeechRecognitionRejectedEventArgs SpeechRecognitionRejectedEventArgs Class

定義

SpeechRecognitionRejected イベントと SpeechRecognitionRejected イベントの情報を提供します。Provides information for the SpeechRecognitionRejected and SpeechRecognitionRejected events.

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

次の例では、"ジャズカテゴリのアーティストの一覧を表示する" または "アルバムの表示 gospel" のような語句を認識しています。The following example recognizes phrases such as "Display the list of artists in the jazz category" or "Display albums gospel". この例では、 SpeechRecognitionRejectedイベントのハンドラーを使用して、音声入力が正しく認識されるように十分な自信を持つ文法の内容と一致しない場合に、コンソールに通知を表示します。The example uses a handler for the SpeechRecognitionRejected event to display a notification in the console when the speech input cannot be matched to the contents of the grammar with sufficient confidence to produce a successful recognition.

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 a grammar.  
        //  Create lists of alternative choices.  
        Choices listTypes = new Choices(new string[] { "albums", "artists" });  
        Choices genres = new Choices(new string[] {   
          "blues", "classical", "gospel", "jazz", "rock" });  

        //  Create a GrammarBuilder object and assemble the grammar components.  
        GrammarBuilder mediaMenu = new GrammarBuilder("Display");  
        mediaMenu.Append("the list of", 0, 1);  
        mediaMenu.Append(listTypes);  
        mediaMenu.Append("in the", 0, 1);  
        mediaMenu.Append(genres);  
        mediaMenu.Append("category", 0, 1);  

        //  Build a Grammar object from the GrammarBuilder.  
        Grammar mediaMenuGrammar = new Grammar(mediaMenu);  
        mediaMenuGrammar.Name = "Media Chooser";  

        // Attach event handlers.  
        recognizer.LoadGrammarCompleted +=  
          new EventHandler<LoadGrammarCompletedEventArgs>(recognizer_LoadGrammarCompleted);  
        recognizer.SpeechRecognized +=  
          new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);  
        recognizer.SpeechRecognitionRejected +=   
          new EventHandler<SpeechRecognitionRejectedEventArgs>(recognizer_SpeechRecognitionRejected);  

        // Load the grammar object to the recognizer.  
        recognizer.LoadGrammarAsync(mediaMenuGrammar);  

        // Keep the console window open.  
        Console.ReadLine();  
      }  
    }  

    // Handle the SpeechRecognitionRejected event.  
    static void recognizer_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)  
    {  
      Console.WriteLine("Speech input was rejected.");  
      foreach (RecognizedPhrase phrase in e.Result.Alternates)  
      {  
        Console.WriteLine("  Rejected phrase: " + phrase.Text);  
        Console.WriteLine("  Confidence score: " + phrase.Confidence);  
      }  
    }  

    // Handle the LoadGrammarCompleted event.  
    static void recognizer_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e)  
    {  
      Console.WriteLine("Grammar loaded: " + e.Grammar.Name);  
    }  

    // Handle the SpeechRecognized event.  
    static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
    {  
      Console.WriteLine("Speech recognized: " + e.Result.Text);  
    }  
  }  
}  

注釈

イベントは、クラスSpeechRecognizerおよびSpeechRecognitionEngineクラスによって発生します。 SpeechRecognitionRejectedThe SpeechRecognitionRejected event is raised by the SpeechRecognizer and SpeechRecognitionEngine classes.

SpeechRecognitionRejectedイベントは、認識操作によって許容される十分な信頼スコアがない場合に、音声認識エンジンによって生成されます。SpeechRecognitionRejected events are generated by a speech recognition engine when none of the alternates from a recognition operation have a high enough confidence score to be accepted. 拒否された語句の詳細についResultては、プロパティを参照してください。Detailed information about rejected phrases is available through the Result property.

SpeechRecognitionRejectedEventArgsはからRecognitionEventArgs派生します。SpeechRecognitionRejectedEventArgs derives from RecognitionEventArgs.

メソッド

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)

適用対象

こちらもご覧ください