RecognitionEventArgs 类

定义

提供有关语音识别事件的信息。Provides information about speech recognition events.

public ref class RecognitionEventArgs abstract : EventArgs
[System.Serializable]
public abstract class RecognitionEventArgs : EventArgs
type RecognitionEventArgs = class
    inherit EventArgs
Public MustInherit Class RecognitionEventArgs
Inherits EventArgs
继承
RecognitionEventArgs
派生
属性

示例

下面的示例为语音识别器的SpeechHypothesizedSpeechRecognizedSpeechRecognitionRejected事件附加处理程序。The following example attaches a handler for the SpeechHypothesized, SpeechRecognized, and SpeechRecognitionRejected events of the speech recognizer. 三个事件的事件参数类型均派生自RecognitionEventArgs, 它用作处理程序中的事件数据参数。The event argument types for the three events all derive from RecognitionEventArgs, which is used as the event data parameter in the handler.

  
// 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以对象的形式获取识别信息。The Result property obtains the recognition information as a RecognitionResult object. 有关语音识别事件的详细信息, 请参阅使用语音识别事件For more information about speech recognition events, see Using Speech Recognition Events.

RecognitionEventArgs是以下类的基础:RecognitionEventArgs is the base for the following classes:

RecognitionEventArgs 派生自 EventArgsRecognitionEventArgs derives from EventArgs.

属性

Result

获取与语音识别事件关联的识别结果数据。Gets the recognition result data associated with the speech recognition event.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅