Grammar.SpeechRecognized Událost

Definice

Vyvolána, když rozpoznávání řeči provádí rozpoznávání pomocí objektu 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 Event SpeechRecognized As EventHandler(Of SpeechRecognizedEventArgs) 
Public Custom Event SpeechRecognized As EventHandler(Of SpeechRecognizedEventArgs) 

Event Type

Příklady

Následující příklad ukazuje použití obslužné rutiny události pro Grammar událost objektu SpeechRecognized . Výsledky rozpoznávání se vypíše do konzoly.

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

Poznámky

Rozpoznávání řeči také vyvolá SpeechRecognized událost, když rozpozná vstup. Událost Grammar objektu SpeechRecognized je vyvolána před událostí rozpoznávání SpeechRecognized řeči . Další informace najdete v událostech SpeechRecognizer.SpeechRecognized, SpeechRecognitionEngine.SpeechRecognizeda RecognizeCompleted .

Všechny úlohy specifické pro konkrétní gramatiku by měly vždy zpracovávat obslužné rutiny pro událost objektu GrammarSpeechRecognized .

Platí pro

Viz také