RecognitionResult.Alternates 属性

定义

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

public:
 property System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::RecognizedPhrase ^> ^ Alternates { System::Collections::ObjectModel::ReadOnlyCollection<System::Speech::Recognition::RecognizedPhrase ^> ^ get(); };
public System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.RecognizedPhrase> Alternates { get; }
member this.Alternates : System.Collections.ObjectModel.ReadOnlyCollection<System.Speech.Recognition.RecognizedPhrase>
Public ReadOnly Property Alternates As ReadOnlyCollection(Of RecognizedPhrase)

属性值

ReadOnlyCollection<RecognizedPhrase>

识别备用项的只读集合。

示例

下面的示例演示事件的处理程序 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);  
  }  
}  

注解

识别 Alternates 按其属性的值进行排序 Confidence 。 给定短语的置信度值指示短语与输入匹配的概率。 置信度值最高的短语是最有可能与输入匹配的短语。

Confidence应该单独计算每个值,而不引用其他值的置信度值 Alternates 。 继承自的属性 RecognitionResult RecognizedPhrase 提供有关置信度最高的短语的详细信息。

集合的一个用途 Alternates 是自动纠错。 例如,在设计目录对话框时,应用程序可能会提示用户检查应用程序是否具有来自识别事件的正确信息,如 "您是否说" Anna "?如果用户显示 "否",则应用程序可以查询用户是否有足够分数的任何备用项 Confidence

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

适用于

另请参阅