SpeechRecognizer.SpeechRecognitionRejected SpeechRecognizer.SpeechRecognitionRejected SpeechRecognizer.SpeechRecognitionRejected SpeechRecognizer.SpeechRecognitionRejected Event


認識機能が読み込んだ音声認識文法のいずれにも一致しない入力を受け取ると発生します。Occurs when the recognizer receives input that does not match any of the speech recognition grammars it has loaded.

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

次の例では、"ジャズカテゴリのアーティストの一覧を表示する" または "アルバムの表示 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("in the", 0, 1);  
        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.  
        // Keep the console window open.  
    // Handle the SpeechRecognitionRejected event.  
    static void recognizer_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)  
      Console.WriteLine("Speech input was rejected.");  
    // 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);  


共有認識エンジンは、読み込まれている音声認識文法で入力が十分な信頼度と一致しないと判断した場合に、このイベントを発生させます。The shared recognizer raises this event if it determines that input does not match with sufficient confidence any of the loaded speech recognition grammars. のプロパティにResult 、拒否RecognitionResult されたオブジェクトが含まれSpeechRecognitionRejectedEventArgsています。The Result property of the SpeechRecognitionRejectedEventArgs contains the rejected RecognitionResult object.

によってSpeechRecognizer管理される共有レコグナイザーの信頼しきい値は、ユーザープロファイルに関連付けられ、Windows レジストリに格納されます。Confidence thresholds for the shared recognizer, managed by SpeechRecognizer, are associated with a user profile and stored in the Windows registry. アプリケーションでは、共有認識エンジンのプロパティに対する変更をレジストリに書き込むことはできません。Applications should not write changes to the registry for the properties of the shared recognizer.

SpeechRecognitionRejectedイベントのデリゲートを作成する場合は、イベントを処理するメソッドを指定します。When you create a delegate for a SpeechRecognitionRejected event, you identify the method that will handle the event. イベントをイベント ハンドラーに関連付けるには、デリゲートのインスタンスをイベントに追加します。To associate the event with your event handler, add an instance of the delegate to the event. デリゲートを削除しない限り、そのイベントが発生すると常にイベント ハンドラーが呼び出されます。The event handler is called whenever the event occurs, unless you remove the delegate. イベントハンドラーデリゲートの詳細については、「イベントとデリゲート」を参照してください。For more information about event-handler delegates, see Events and Delegates.