Grammar.SpeechRecognized Evento

Definición

Se genera cuando un reconocedor de voz realiza el reconocimiento usando el objeto Grammar.Raised when a speech recognizer performs recognition using the Grammar object.

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

Ejemplos

En el ejemplo siguiente se muestra el uso de un controlador de eventos para el evento SpeechRecognized del objeto Grammar.The following example shows the use of an event handler for the Grammar object's SpeechRecognized event. Genera los resultados del reconocimiento en la consola.It outputs the recognition results to the console.

public partial class Form1 : Form  
{  
  SpeechRecognitionEngine sre;  
  
  public Form1()  
  {  
  InitializeComponent();  
  
  // Create an in-process speech recognizer.  
  sre = new SpeechRecognitionEngine();  
  
  // Configure input to the speech recognizer.  
  sre.SetInputToDefaultAudioDevice();  
  
  // Create a simple grammar and load it.  
  Grammar testGrammar = new Grammar(new GrammarBuilder("testing"));  
  sre.LoadGrammarAsync(testGrammar);  
  
  // Add a handler for the grammar's speech recognized event.  
  testGrammar.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(testGrammar_SpeechRecognized);  
  
  // Start asynchronous speech recognition.  
  sre.RecognizeAsync();  
  }  
  
  // Handle the grammar's SpeechRecognized event, output the recognized text.  
  void testGrammar_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
  {  
    Console.WriteLine("Recognized text: " + e.Result.Text);  
  }  
}  

Comentarios

El reconocedor de voz también genera un evento SpeechRecognized cuando reconoce la entrada.The speech recognizer also raises a SpeechRecognized event when it recognizes input. El evento de @no__t 1 del objeto Grammar se genera antes que el evento @no__t 2 del reconocedor de voz.The Grammar object's SpeechRecognized event is raised prior to the speech recognizer's SpeechRecognized event . Para obtener más información, vea los eventos SpeechRecognizer.SpeechRecognized, SpeechRecognitionEngine.SpeechRecognized y RecognizeCompleted.For more information, see the SpeechRecognizer.SpeechRecognized, SpeechRecognitionEngine.SpeechRecognized, and RecognizeCompleted events.

Las tareas específicas de una gramática determinada siempre deben controlarse mediante los controladores del evento SpeechRecognized del objeto Grammar.Any tasks specific to a particular grammar should always be handled by handlers for the Grammar object's SpeechRecognized event.

Se aplica a

Consulte también: