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

如需有關語音辨識和使用辨識替代項的詳細資訊,請參閱 語音 識別和 使用語音辨識事件

適用於

另請參閱