RecognizedPhrase 類別

定義

包含語音辨識器所產生的有關已辨識輸入的詳細資訊。

public ref class RecognizedPhrase
[System.Serializable]
public class RecognizedPhrase
public class RecognizedPhrase
[<System.Serializable>]
type RecognizedPhrase = class
type RecognizedPhrase = class
Public Class RecognizedPhrase
繼承
RecognizedPhrase
衍生
屬性

範例

下列範例顯示 、 SpeechRecognizer.SpeechRecognizedGrammar.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);  
  }  
}  

備註

此類別包含語音辨識作業期間所處理之單字和片語的詳細資訊,包括下列各項:

  • 屬性 Grammar 會參考 Grammar 辨識器用來識別輸入的 。

  • 屬性 Text 包含片語的正規化文字。

  • 屬性 Semantics 會參考結果中包含的語意資訊。 語意資訊是索引鍵名稱和相關聯語意資料的字典。

  • 屬性 Words 包含物件的已排序集合 RecognizedWordUnit ,這些物件代表輸入中每個辨識的單字。 每個單字單位都包含對應字組的顯示格式、語彙格式和發音資訊。

  • 屬性 ReplacementWordUnits 包含特殊字組替代的相關資訊。

  • HomophonesHomophoneGroupId 屬性包含相同或類似發音的辨識替代專案相關資訊。

  • 屬性的值 Confidence 表示語音辨識器所指派的確定程度,辨識的片語符合輸入。

語音辨識器會在 繼承自 RecognizedPhrase 的 物件中 RecognitionResult 傳回辨識結果。 辨識結果 Alternates 屬性包含物件的已排序集合 RecognizedPhrase ,每個物件都是辨識器輸入的可能相符專案。

屬性

Confidence

取得辨識器指派的值,這個值表示 RecognizedPhrase 符合指定之輸入的可能性。

Grammar

取得 語音辨識器用來傳回 GrammarRecognizedPhrase

HomophoneGroupId

取得片語同音字群組的識別項。

Homophones

取得與此辨識片語發音相同的辨識替代項目集合。

ReplacementWordUnits

取得在語音轉文字正規化過程中,語音辨識器變更之文字的相關資訊。

Semantics

取得與已辨識片語相關聯的語意資訊。

Text

取得語音辨識器從已辨識輸入產生的正規化文字。

Words

取得語音辨識器從已辨識輸入產生的單字。

方法

ConstructSmlFromSemantics()

傳回 RecognizedPhrase 物件中語意資訊的語意標記語言 (SML) 文件。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱