Condividi tramite


Grammar.SpeechRecognized Evento

Definizione

Generato quando il riconoscimento vocale esegue il riconoscimento utilizzando l'oggetto 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 evento

Esempio

Nell'esempio seguente viene illustrato l'uso di un gestore eventi per l'evento Grammar dell'oggetto SpeechRecognized . Restituisce i risultati del riconoscimento nella 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);
  }
}

Commenti

Il riconoscimento vocale genera anche un SpeechRecognized evento quando riconosce l'input. L'evento Grammar dell'oggetto SpeechRecognized viene generato prima dell'evento del SpeechRecognized riconoscimento vocale. Per altre informazioni, vedere gli SpeechRecognizer.SpeechRecognizedeventi , SpeechRecognitionEngine.SpeechRecognizede RecognizeCompleted .

Tutte le attività specifiche di una particolare grammatica devono sempre essere gestite dai gestori per l'evento Grammar dell'oggetto SpeechRecognized .

Si applica a

Vedi anche