RecognitionResult 类

定义

包含有关由 SpeechRecognitionEngineSpeechRecognizer 实例识别的输入的详细信息。Contains detailed information about input that was recognized by instances of SpeechRecognitionEngine or SpeechRecognizer.

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
type RecognitionResult = class
    inherit RecognizedPhrase
    interface ISerializable
Public NotInheritable Class RecognitionResult
Inherits RecognizedPhrase
Implements ISerializable
继承
RecognitionResult
属性
实现

示例

下面SpeechRecognized的示例演示了SpeechRecognitionEngineSpeechRecognizer对象的事件的处理程序, 以及有关关联RecognitionResult的的某些信息。The following example shows a handler for the SpeechRecognized event of a SpeechRecognitionEngine or SpeechRecognizer object, and some of the information about the associated 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 , 并提供有关语音识别的详细信息, 其中包括:This class derives from RecognizedPhrase and provides detailed information about speech recognition, including the following:

  • 属性引用识别器用于标识语音的GrammarGrammarThe Grammar property references the Grammar that the recognizer used to identify the speech.

  • Text属性包含短语的规范化文本。The Text property contains the normalized text for the phrase. 有关文本规范化的详细信息, 请ReplacementText参阅。For more information about text normalization, see ReplacementText.

  • Semantics属性引用结果中包含的语义信息。The Semantics property references the semantic information contained in the result. 语义信息是密钥名称和关联语义数据的字典。The semantic information is a dictionary of the key names and associated semantic data.

  • 属性包含RecognizedPhrase对象的集合, 这些对象表示音频输入的其他候选解释。 AlternatesThe Alternates property contains a collection of RecognizedPhrase objects that represent other candidate interpretations of the audio input. 有关详细信息,请参阅 AlternatesSee Alternates for additional information.

  • 属性包含RecognizedWordUnit对象的有序集合, 这些对象表示输入中每个识别的单词。 WordsThe Words property contains an ordered collection of RecognizedWordUnit objects that represent each recognized word in the input. RecognizedWordUnit个包含相应单词的显示格式、词法格式和发音信息。Each RecognizedWordUnit contains display format, lexical format, and pronunciation information for the corresponding word.

SpeechRecognitionEngine、和SpeechRecognizer类的某些成员可以生成。 RecognitionResult GrammarCertain members of the SpeechRecognitionEngine, SpeechRecognizer, and Grammar classes can generate a RecognitionResult. 有关详细信息, 请参阅以下方法和事件。For more information, see the following methods and events.

有关识别事件的详细信息, 请参阅使用语音识别事件For more information about recognition events, see Using Speech Recognition Events.

属性

Alternates

获取可能的匹配集合,以便输入至语音识别器。Gets the collection of possible matches for input to the speech recognizer.

Audio

获取与识别结果关联的音频。Gets the audio associated with the recognition result.

Confidence

获取识别器分配的值,此值表示 RecognizedPhrase 与给定输入匹配的可能性。Gets a value, assigned by the recognizer, that represents the likelihood that a RecognizedPhrase matches a given input.

(继承自 RecognizedPhrase)
Grammar

获取语音识别器用于返回 RecognizedPhraseGrammarGets the Grammar that the speech recognizer used to return the RecognizedPhrase.

(继承自 RecognizedPhrase)
HomophoneGroupId

获取短语同音字组的标识符。Gets the identifier for the homophone group for the phrase.

(继承自 RecognizedPhrase)
Homophones

获取识别备用项的集合,这些备用项具有与此识别语法一样的发音。Gets a collection of the recognition alternates that have the same pronunciation as this recognized phrase.

(继承自 RecognizedPhrase)
ReplacementWordUnits

获取语音识别器作为语音到文本规范化一部分更改的文本的相关信息。Gets information about the text that the speech recognizer changed as part of speech-to-text normalization.

(继承自 RecognizedPhrase)
Semantics

获取与所识别的短语相关的语义信息。Gets the semantic information that is associated with the recognized phrase.

(继承自 RecognizedPhrase)
Text

获取语音识别器从识别的输入生成的规范化文本。Gets the normalized text generated by a speech recognizer from recognized input.

(继承自 RecognizedPhrase)
Words

获取语音识别器从识别的输入生成的词语。Gets the words generated by a speech recognizer from recognized input.

(继承自 RecognizedPhrase)

方法

ConstructSmlFromSemantics()

RecognizedPhrase 对象中的语义信息返回语义标记语言 (SML) 文档。Returns a semantic markup language (SML) document for the semantic information in the RecognizedPhrase object.

(继承自 RecognizedPhrase)
Equals(Object)

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

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

在识别结果中获取与特定范围单词关联的音频部分。Gets a section of the audio that is associated with a specific range of words in the recognition result.

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)

显式接口实现

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

使用序列化目标对象所需的数据填充 SerializationInfo 的实例。Populates a SerializationInfo instance with the data needed to serialize the target object.

适用于

另请参阅