RecognitionResult.Alternates 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得多個可能匹配的集合,輸入語音識別器。
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)
屬性值
識別的唯讀集合交替進行。
範例
以下範例展示了事件的 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 高的替代選項。
欲了解更多語音辨識及辨識替代方案的使用,請參閱語音 辨識 與 語音辨識事件。