RecognitionEventArgs 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供有关语音识别事件的信息。
public ref class RecognitionEventArgs abstract : EventArgs
C#
public abstract class RecognitionEventArgs : EventArgs
C#
[System.Serializable]
public abstract class RecognitionEventArgs : EventArgs
type RecognitionEventArgs = class
inherit EventArgs
[<System.Serializable>]
type RecognitionEventArgs = class
inherit EventArgs
Public MustInherit Class RecognitionEventArgs
Inherits EventArgs
- 继承
- 派生
- 属性
以下示例附加语音识别器 、 SpeechHypothesizedSpeechRecognized和 SpeechRecognitionRejected 事件的处理程序。 这三个事件的事件参数类型都派生自 RecognitionEventArgs,后者用作处理程序中的事件数据参数。
C#
// Initialize the speech recognizer.
private void Initialize(SpeechRecognitionEngine recognizer)
{
// Attach handlers for the SpeechHypothesized, SpeechRecognitionRejected,
// and SpeechRecognized events.
recognizer.SpeechHypothesized +=
new EventHandler<SpeechHypothesizedEventArgs>(DisplayResult);
recognizer.SpeechRecognitionRejected +=
new EventHandler<SpeechRecognitionRejectedEventArgs>(DisplayResult);
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(DisplayResult);
// Add other initialization code here.
}
// Handle the SpeechHypothesized, SpeechRecognitionRejected,
// and SpeechRecognized events.
private void DisplayResult(object sender, RecognitionEventArgs e)
{
if (e is SpeechHypothesizedEventArgs)
{
Console.WriteLine("Speech hypothesized:");
}
else if (e is SpeechRecognitionRejectedEventArgs)
{
Console.WriteLine("Speech recognition rejected:");
}
else if (e is SpeechRecognizedEventArgs)
{
Console.WriteLine("Speech recognized:");
}
// Add code to handle the event.
}
属性 Result 以 对象的形式 RecognitionResult 获取识别信息。 有关语音识别事件的详细信息,请参阅 使用语音识别事件。
RecognitionEventArgs 是以下类的基础:
RecognitionEventArgs 派生自 EventArgs。
Result |
获取与语音识别事件关联的识别结果数据。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |