RecognitionEventArgs 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供有关语音识别事件的信息。
public ref class RecognitionEventArgs abstract : EventArgs
public abstract class RecognitionEventArgs : EventArgs
[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,后者用作处理程序中的事件数据参数。
// 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) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |