Grammar.SpeechRecognized Evento

Definición

Se genera cuando un reconocedor de voz realiza el reconocimiento usando el objeto Grammar.

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 Custom Event SpeechRecognized As EventHandler(Of SpeechRecognizedEventArgs) 
Public Event SpeechRecognized As EventHandler(Of SpeechRecognizedEventArgs) 

Tipo de evento

Ejemplos

En el ejemplo siguiente se muestra el uso de un controlador de eventos para el Grammar evento del SpeechRecognized objeto. Genera los resultados de reconocimiento en la consola.

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 SpeechRecognized evento cuando reconoce la entrada. El Grammar evento del SpeechRecognized objeto se genera antes del evento del reconocedor de SpeechRecognized voz . Para obtener más información, vea los SpeechRecognizer.SpeechRecognizedeventos , SpeechRecognitionEngine.SpeechRecognizedy RecognizeCompleted .

Las tareas específicas de una gramática determinada siempre deben controlarse mediante controladores para el Grammar evento del SpeechRecognized objeto.

Se aplica a

Consulte también