Grammar.SpeechRecognized Kejadian
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Dimunculkan saat pengenal ucapan melakukan pengenalan menggunakan Grammar objek .
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)
Jenis Acara
Contoh
Contoh berikut menunjukkan penggunaan penanganan aktivitas untuk Grammar peristiwa objek SpeechRecognized . Ini menghasilkan hasil pengenalan ke konsol.
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);
}
}
Keterangan
Pengenal ucapan juga memunculkan SpeechRecognized
peristiwa ketika mengenali input. Peristiwa Grammar objek SpeechRecognized dinaikkan sebelum peristiwa pengenal SpeechRecognized
ucapan . Untuk informasi selengkapnya, lihat SpeechRecognizer.SpeechRecognizedperistiwa , , SpeechRecognitionEngine.SpeechRecognizeddan RecognizeCompleted .
Setiap tugas khusus untuk tata bahasa tertentu harus selalu ditangani oleh penangan untuk Grammar peristiwa objek SpeechRecognized .