SpeechRecognitionRejectedEventArgs Třída

Definice

Poskytuje informace o událostech SpeechRecognitionRejected a SpeechRecognitionRejected .

public ref class SpeechRecognitionRejectedEventArgs : System::Speech::Recognition::RecognitionEventArgs
[System.Serializable]
public class SpeechRecognitionRejectedEventArgs : System.Speech.Recognition.RecognitionEventArgs
public class SpeechRecognitionRejectedEventArgs : System.Speech.Recognition.RecognitionEventArgs
[<System.Serializable>]
type SpeechRecognitionRejectedEventArgs = class
    inherit RecognitionEventArgs
type SpeechRecognitionRejectedEventArgs = class
    inherit RecognitionEventArgs
Public Class SpeechRecognitionRejectedEventArgs
Inherits RecognitionEventArgs
Dědičnost
SpeechRecognitionRejectedEventArgs
Atributy

Příklady

Následující příklad rozpoznává fráze jako "Zobrazit seznam umělců v kategorii jazz" nebo "Zobrazit alba gospel". Příklad používá obslužnou rutinu SpeechRecognitionRejected události k zobrazení oznámení v konzole, když vstup řeči nemůže být spárován s obsahem gramatiky s dostatečnou jistotou, aby bylo možné úspěšně rozpoznat.

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

Poznámky

Událost SpeechRecognitionRejected je vyvolána třídami SpeechRecognizer a SpeechRecognitionEngine .

Události SpeechRecognitionRejected jsou generovány modulem rozpoznávání řeči, když žádná z alternativních operací rozpoznávání nemá dostatečně vysoké skóre spolehlivosti, aby bylo možné přijmout. Podrobné informace o odmítnutých frázích jsou k dispozici prostřednictvím Result vlastnosti .

SpeechRecognitionRejectedEventArgs je odvozen z RecognitionEventArgs.

Vlastnosti

Result

Získá data výsledku rozpoznávání přidružená k události rozpoznávání řeči.

(Zděděno od RecognitionEventArgs)

Metody

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí hashovací funkce.

(Zděděno od Object)
GetType()

Získá aktuální Type instanci.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také