RecognizedWordUnit 類別

定義

提供辨識語音的不可部分完成的單位。Provides the atomic unit of recognized speech.

public ref class RecognizedWordUnit
[System.Serializable]
public class RecognizedWordUnit
type RecognizedWordUnit = class
Public Class RecognizedWordUnit
繼承
RecognizedWordUnit
屬性

範例

下列範例顯示產生字串的公用程式常式(stringFromWordArray)。The following example shows a utility routine (stringFromWordArray) that generates strings. 這些字串包含詞法輸出(使用 LexicalForm)、正規化的文字(使用 Text),或國際拼音字母中的語音字元(使用 Pronunciation)。The strings contain lexical output (using LexicalForm), normalized text (using Text), or phonetic characters from the International Phonetic Alphabet (using Pronunciation). 字串會使用從 RecognizedWordUnit 物件 ReadOnlyCollection<T>DisplayAttributes 屬性取得的 DisplayAttributes 物件進行格式化。Strings are formatted using DisplayAttributes objects obtained from the DisplayAttributes property from a ReadOnlyCollection<T> of RecognizedWordUnit objects. RecognizedWordUnit 物件是從 RecognizedPhrase 物件上的 Words 屬性取得。The RecognizedWordUnit objects are obtained from the Words property on the RecognizedPhrase object.

  
internal enum WordType   
{  
  Text,  
  Normalized = Text,  
  Lexical,  
  Pronunciation  
}  
internal static string stringFromWordArray(ReadOnlyCollection<RecognizedWordUnit> words, WordType type)   
{  
  string text = "";  
  foreach (RecognizedWordUnit word in words)   
  {  
    string wordText = "";  
    if (type == WordType.Text || type == WordType.Normalized)   
    {  
      wordText = word.Text;  
    }   
    else if (type == WordType.Lexical)   
    {  
      wordText = word.LexicalForm;  
    }   
    else if (type == WordType.Pronunciation)   
    {  
      wordText = word.Pronunciation;  
    }   
    else   
    {  
      throw new InvalidEnumArgumentException(String.Format("[0}: is not a valid input", type));  
    }  
    // Use display attribute  
  
    if ((word.DisplayAttributes & DisplayAttributes.OneTrailingSpace) != 0)   
    {  
      wordText += " ";  
    }  
    if ((word.DisplayAttributes & DisplayAttributes.TwoTrailingSpaces) != 0)  
    {  
      wordText += "  ";  
    }  
    if ((word.DisplayAttributes & DisplayAttributes.ConsumeLeadingSpaces) != 0)   
    {  
      wordText = wordText.TrimStart();  
    }  
    if ((word.DisplayAttributes & DisplayAttributes.ZeroTrailingSpaces) != 0)  
    {  
      wordText = wordText.TrimEnd();  
    }  
  
    text += wordText;  
  
  }  
  return text;  
}  

備註

辨識引擎傳回的所有結果都是由 RecognizedWordUnit 物件所構成。All results returned by a recognition engine are constructed of RecognizedWordUnit objects.

透過 RecognizedPhrase 物件上的 Words 屬性,可存取任何辨識作業的 RecognizedWordUnit 物件陣列。An array of RecognizedWordUnit objects is accessible for any recognition operation through the Words property on the RecognizedPhrase object.

除了提供辨識確定性(Confidence)的量值之外,RecognizedWordUnit 實例還提供:In addition to providing a measure of recognition certainty (Confidence) a RecognizedWordUnit instance provides:

  • 已辨識單字的正規化和精確(或詞法)文字標記法。Normalized and exact (or lexical) text representations for a recognized word. 如需詳細資訊,請參閱 ReplacementTextTextLexicalFormFor more information, see ReplacementText, Text, and LexicalForm.

  • 發音資訊:使用來自支援的語音字母的字元,例如國際語音字母(.IPA)或通用電話集(UPS)。Pronunciation information using characters from a supported phonetic alphabet, such as the International Phonetic Alphabet (IPA) or the Universal Phone Set (UPS). 如需詳細資訊,請參閱<Pronunciation>。For more information see Pronunciation.

  • 列印的格式。Formatting for printing. 如需詳細資訊,請參閱 DisplayAttributes 類別及其 DisplayAttributes 屬性。For more information see the DisplayAttributes class and its DisplayAttributes property.

建構函式

RecognizedWordUnit(String, Single, String, String, DisplayAttributes, TimeSpan, TimeSpan)

初始化 RecognizedWordUnit 類別的新執行個體。Initializes a new instance of the RecognizedWordUnit class.

屬性

Confidence

取得指派給辨識器的值,這個值表示所辨識的字符合指定之輸入的可能性。Gets a value, assigned by the recognizer, that represents the likelihood that a recognized word matches a given input.

DisplayAttributes

取得格式化資訊,這項資訊會用來從目前的 RecognizedWordUnit 執行個體建立文字輸出。Gets formatting information used to create the text output from the current RecognizedWordUnit instance.

LexicalForm

取得所辨識之單字的未標準化文字。Gets the unnormalized text of a recognized word.

Pronunciation

取得所辨識之單字的語音拼法。Gets the phonetic spelling of a recognized word.

Text

取得所辨識之單字的標準化文字。Gets the normalized text for a recognized word.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱