RecognizedWordUnit.Pronunciation 屬性

定義

取得所辨識之單字的語音拼法。

public:
 property System::String ^ Pronunciation { System::String ^ get(); };
public string Pronunciation { get; }
member this.Pronunciation : string
Public ReadOnly Property Pronunciation As String

屬性值

使用支援的語音字母(例如,國際音標 (IPA) 或通用拼音集 (UPS))的字元字串。

範例

下列範例顯示公用程式常式,其會產生三種可能格式之一的字串:使用) 的語彙 (、使用 LexicalFormText) 正規化 (,以及使用) 的 Pronunciation 注音 (。 文字輸出是從 物件的 取得 ReadOnlyCollection<T>RecognizedWordUnit ,從 物件的 屬性 RecognizedPhrase 取得 Words

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;  
}  

備註

的內容 Pronunciation 會指出語音辨識引擎用來比對語音輸入與其其中一個載入 Grammar 物件的發音。 發音可以定義在語音辨識引擎的內部語彙、從載入 Grammar 物件中的辨識文法連結的語彙檔中,或內嵌在載入 Grammar 物件的辨識文法中。 語音辨識引擎也可能為不常見字組建立發音,其發音未定義于語音辨識引擎目前可存取的語彙或文法中。

許多以 Windows 為基礎的 Unicode 字型,例如 Courier New,都支援顯示 IPA 字串。 如需詳細資訊,請參閱 國際語音字母

適用於

另請參閱