RecognitionResult 类

定义

包含有关由 SpeechRecognitionEngineSpeechRecognizer 实例识别的输入的详细信息。

public ref class RecognitionResult sealed : System::Speech::Recognition::RecognizedPhrase, System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class RecognitionResult : System.Speech.Recognition.RecognizedPhrase, System.Runtime.Serialization.ISerializable
public sealed class RecognitionResult : System.Speech.Recognition.RecognizedPhrase, System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type RecognitionResult = class
    inherit RecognizedPhrase
    interface ISerializable
type RecognitionResult = class
    inherit RecognizedPhrase
    interface ISerializable
Public NotInheritable Class RecognitionResult
Inherits RecognizedPhrase
Implements ISerializable
继承
RecognitionResult
属性
实现

示例

以下示例显示了 或 SpeechRecognizer 对象的 事件的SpeechRecognitionEngine处理程序SpeechRecognized,以及有关关联的 RecognitionResult的一些信息。

// Handle the SpeechRecognized event.   
void SpeechRecognizedHandler(object sender, SpeechRecognizedEventArgs e)  
{  
  if (e.Result == null) return;  

  // Add event handler code here.  

  // The following code illustrates some of the information available  
  // in the recognition result.  
  Console.WriteLine("Grammar({0}), {1}: {2}",  
    e.Result.Grammar.Name, e.Result.Audio.Duration, e.Result.Text);  

  // Display the semantic values in the recognition result.  
  foreach (KeyValuePair<String, SemanticValue> child in e.Result.Semantics)  
  {  
    Console.WriteLine(" {0} key: {1}",  
      child.Key, child.Value.Value ?? "null");  
  }  
  Console.WriteLine();  

  // Display information about the words in the recognition result.  
  foreach (RecognizedWordUnit word in e.Result.Words)  
  {  
    RecognizedAudio audio = e.Result.GetAudioForWordRange(word, word);  
    Console.WriteLine(" {0,-10} {1,-10} {2,-10} {3} ({4})",  
      word.Text, word.LexicalForm, word.Pronunciation,  
      audio.Duration, word.DisplayAttributes);  
  }  

  // Display the recognition alternates for the result.  
  foreach (RecognizedPhrase phrase in e.Result.Alternates)  
  {  
    Console.WriteLine(" alt({0}) {1}", phrase.Confidence, phrase.Text);  
  }  
}  

注解

此类派生自 RecognizedPhrase 并提供有关语音识别的详细信息,包括以下内容:

  • 属性 Grammar 引用 Grammar 识别器用于标识语音的 。

  • 属性 Text 包含短语的规范化文本。 有关文本规范化的详细信息,请参阅 ReplacementText

  • 属性 Semantics 引用结果中包含的语义信息。 语义信息是键名称和关联的语义数据的字典。

  • 属性 Alternates 包含对象的集合 RecognizedPhrase ,这些对象表示音频输入的其他候选解释。 有关详细信息,请参阅 Alternates

  • 属性 Words 包含对象的有序集合 RecognizedWordUnit ,这些对象表示输入中每个识别的单词。 每个都包含 RecognizedWordUnit 相应单词的显示格式、词法格式和发音信息。

、 和 类的某些成员SpeechRecognitionEngine可以生成 RecognitionResultGrammarSpeechRecognizer 有关详细信息,请参阅以下方法和事件。

有关识别事件的详细信息,请参阅 使用语音识别事件

属性

Alternates

获取可能的匹配集合,以便输入至语音识别器。

Audio

获取与识别结果关联的音频。

Confidence

获取识别器分配的值,此值表示 RecognizedPhrase 与给定输入匹配的可能性。

(继承自 RecognizedPhrase)
Grammar

获取语音识别器用于返回 GrammarRecognizedPhrase

(继承自 RecognizedPhrase)
HomophoneGroupId

获取短语同音字组的标识符。

(继承自 RecognizedPhrase)
Homophones

获取识别备用项的集合,这些备用项具有与此识别语法一样的发音。

(继承自 RecognizedPhrase)
ReplacementWordUnits

获取语音识别器作为语音到文本规范化一部分更改的文本的相关信息。

(继承自 RecognizedPhrase)
Semantics

获取与所识别的短语相关的语义信息。

(继承自 RecognizedPhrase)
Text

获取语音识别器从识别的输入生成的规范化文本。

(继承自 RecognizedPhrase)
Words

获取语音识别器从识别的输入生成的词语。

(继承自 RecognizedPhrase)

方法

ConstructSmlFromSemantics()

RecognizedPhrase 对象中的语义信息返回语义标记语言 (SML) 文档。

(继承自 RecognizedPhrase)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetAudioForWordRange(RecognizedWordUnit, RecognizedWordUnit)

在识别结果中获取与特定范围单词关联的音频部分。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

使用序列化目标对象所需的数据填充 SerializationInfo 的实例。

适用于

另请参阅