RecognizedPhrase 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
包含由语音识别器生成的有关识别的输入的详细信息。
public ref class RecognizedPhrasepublic class RecognizedPhrase[System.Serializable]
public class RecognizedPhrasetype RecognizedPhrase = class[<System.Serializable>]
type RecognizedPhrase = classPublic Class RecognizedPhrase- 继承
- 
				RecognizedPhrase
- 派生
- 属性
示例
以下示例演示 、 SpeechRecognizer.SpeechRecognized或 Grammar.SpeechRecognized 事件的处理程序SpeechRecognitionEngine.SpeechRecognized以及与 对象关联的RecognitionResult某些信息。 RecognitionResult 类是从 RecognizedPhrase 类派生的。
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("Recognition result summary:");
  Console.WriteLine(
    "  Recognized phrase: {0}\n" +
    "  Confidence score {1}\n" +
    "  Grammar used: {2}\n",
    e.Result.Text, e.Result.Confidence, e.Result.Grammar.Name);
  // Display the semantic values in the recognition result.
  Console.WriteLine("  Semantic results:");
  foreach (KeyValuePair<String, SemanticValue> child in e.Result.Semantics)
  {
    Console.WriteLine("    The {0} city is {1}",
      child.Key, child.Value.Value ?? "null");
  }
  Console.WriteLine();
  // Display information about the words in the recognition result.
  Console.WriteLine("  Word summary: ");
  foreach (RecognizedWordUnit word in e.Result.Words)
  {
    Console.WriteLine(
      "    Lexical form ({1})" +
      " Pronunciation ({0})" +
      " Display form ({2})",
      word.Pronunciation, word.LexicalForm, word.DisplayAttributes);
  }
  // Display information about the audio in the recognition result.
  Console.WriteLine("  Input audio summary:\n" +
    "    Candidate Phrase at:       {0} mSec\n" +
    "    Phrase Length:             {1} mSec\n" +
    "    Input State Time:          {2}\n" +
    "    Input Format:              {3}\n",
    e.Result.Audio.AudioPosition,
    e.Result.Audio.Duration,
    e.Result.Audio.StartTime,
    e.Result.Audio.Format.EncodingFormat);
  // Display information about the alternate recognitions in the recognition result.
  Console.WriteLine("  Alternate phrase collection:");
  foreach (RecognizedPhrase phrase in e.Result.Alternates)
  {
    Console.WriteLine("    Phrase: " + phrase.Text);
    Console.WriteLine("    Confidence score: " + phrase.Confidence);
  }
}
注解
此类包含有关在语音识别操作期间处理的字词和短语的详细信息,包括以下内容:
- 属性 Text 包含短语的规范化文本。 
- 属性 Semantics 引用结果中包含的语义信息。 语义信息是键名称和关联的语义数据的字典。 
- 属性 Words 包含对象的有序集合 RecognizedWordUnit ,这些对象表示输入中每个识别的单词。 每个单词单元都包含相应单词的显示格式、词法格式和发音信息。 
- 属性 ReplacementWordUnits 包含有关专用词替换的信息。 
- Homophones和 HomophoneGroupId 属性包含有关具有相同或类似发音的识别替代项的信息。 
- 属性的值 Confidence 指示由语音识别器分配的确定性程度,即识别的短语与输入匹配。 
语音识别器返回继承自 RecognizedPhrase的 RecognitionResult 对象的识别结果。 识别结果 Alternates 属性包含一个有序的对象 RecognizedPhrase 集合,其中每个对象都是识别器输入的可能匹配项。
属性
| Confidence | 获取识别器分配的值,此值表示 RecognizedPhrase 与给定输入匹配的可能性。 | 
| Grammar | 获取语音识别器用于返回 Grammar 的 RecognizedPhrase。 | 
| HomophoneGroupId | 获取短语同音字组的标识符。 | 
| Homophones | 获取识别备用项的集合,这些备用项具有与此识别语法一样的发音。 | 
| ReplacementWordUnits | 获取语音识别器作为语音到文本规范化一部分更改的文本的相关信息。 | 
| Semantics | 获取与所识别的短语相关的语义信息。 | 
| Text | 获取语音识别器从识别的输入生成的规范化文本。 | 
| Words | 获取语音识别器从识别的输入生成的词语。 | 
方法
| ConstructSmlFromSemantics() | 为 RecognizedPhrase 对象中的语义信息返回语义标记语言 (SML) 文档。 | 
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) |