Grammar.SpeechRecognized イベント
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
音声認識エンジンが Grammar オブジェクトを使用して認識を実行すると発生します。
public:
event EventHandler<System::Speech::Recognition::SpeechRecognizedEventArgs ^> ^ SpeechRecognized;
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)
イベントの種類
例
次の例は、 Grammar オブジェクトの SpeechRecognized イベントにイベント ハンドラーを使用する方法を示しています。 認識結果がコンソールに出力 されます。
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);
}
}
注釈
音声認識エンジンは、入力を認識すると SpeechRecognized イベントも発生します。
Grammar オブジェクトのSpeechRecognized イベントは、音声認識エンジンのSpeechRecognized イベントの前に発生します。 詳細については、 SpeechRecognizer.SpeechRecognized、 SpeechRecognitionEngine.SpeechRecognized、および RecognizeCompleted イベントを参照してください。
特定の文法に固有のタスクは、常に、 Grammar オブジェクトの SpeechRecognized イベントのハンドラーによって処理される必要があります。