SpeechRecognitionRejectedEventArgs SpeechRecognitionRejectedEventArgs SpeechRecognitionRejectedEventArgs SpeechRecognitionRejectedEventArgs Class

Definizione

Fornisce informazioni per gli eventi SpeechRecognitionRejected e 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
Ereditarietà
SpeechRecognitionRejectedEventArgsSpeechRecognitionRejectedEventArgsSpeechRecognitionRejectedEventArgsSpeechRecognitionRejectedEventArgs
Attributi

Esempi

Nell'esempio seguente riconosce le frasi, ad esempio "Visualizzare l'elenco degli artisti nella categoria jazz" o "Visualizzare gospel album".The following example recognizes phrases such as "Display the list of artists in the jazz category" or "Display albums gospel". L'esempio Usa un gestore per il SpeechRecognitionRejected evento per visualizzare una notifica nella console quando il riconoscimento vocale di input non è possibile associare al contenuto della grammatica di fiducia sufficiente per generare un riconoscimento corretto.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);  
    }  
  }  
}  

Commenti

Il SpeechRecognitionRejected evento viene generato mediante il SpeechRecognizer e SpeechRecognitionEngine classi.The SpeechRecognitionRejected event is raised by the SpeechRecognizer and SpeechRecognitionEngine classes.

SpeechRecognitionRejected gli eventi vengono generati da un motore di riconoscimento vocale quando nessuna delle alternative da un'operazione di riconoscimento è un punteggio di confidenza sufficientemente elevato da accettare.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. Informazioni dettagliate sulle frasi rifiutate sono disponibili tramite il Result proprietà.Detailed information about rejected phrases is available through the Result property.

SpeechRecognitionRejectedEventArgs deriva da RecognitionEventArgs.SpeechRecognitionRejectedEventArgs derives from RecognitionEventArgs.

Metodi

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

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)

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

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)

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

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Inherited from Object)

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

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)

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

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Inherited from Object)

Proprietà

Result Result Result Result

Ottiene i dati dei risultati di riconoscimento associati all'evento di riconoscimento vocale.Gets the recognition result data associated with the speech recognition event.

(Inherited from RecognitionEventArgs)

Si applica a

Vedi anche