PromptBuilder.AppendTextWithPronunciation(String, String) PromptBuilder.AppendTextWithPronunciation(String, String) PromptBuilder.AppendTextWithPronunciation(String, String) PromptBuilder.AppendTextWithPronunciation(String, String) Method

定義

將文字附加至 PromptBuilder 物件,並指定文字的發音。Appends text to the PromptBuilder object and specifies the pronunciation for the text.

public:
 void AppendTextWithPronunciation(System::String ^ textToSpeak, System::String ^ pronunciation);
public void AppendTextWithPronunciation (string textToSpeak, string pronunciation);
member this.AppendTextWithPronunciation : string * string -> unit
Public Sub AppendTextWithPronunciation (textToSpeak As String, pronunciation As String)

參數

textToSpeak
String String String String

字串,包含使用某語言傳統字母之單字的書寫形式。A string containing the written form of the word using the conventional alphabet for a language.

pronunciation
String String String String

字串,包含要從國際音標 (IPA) 讀出的音素。A string containing phones to be spoken from the International Phonetic Alphabet (IPA).

範例

下列範例會初始化PromptBuilder類別的新實例。The following example initializes a new instance of the PromptBuilder class. 然後, 它會將文字字串 "My name is" 附加至實例。It then appends the text string "My name is" to the instance. 最後, 它會附加包含正確名稱 "DuBois" 的字串, 並指定名稱的發音。Finally, it appends a string containing the proper name "DuBois" and specifies the pronunciation of the name.

public void ProperName()  
{  
    PromptBuilder builder = new PromptBuilder();  
    builder.AppendText("My name is");  
  
    // Add a proper name and its pronunciation.  
    builder.AppendTextWithPronunciation("DuBois", "duˈbwɑ");     
}  

下列標記顯示此PromptBuilder物件產生的 SSML。The following markup shows the SSML that this PromptBuilder object generates.

<speak xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-us">  
  My name is <phoneme ph="duˈbwɑ"> DuBois </phoneme>  
</speak>  

備註

合成器會說出pronunciation參數的內容, 而不是textToSpeak參數的內容。The synthesizer speaks the contents of the pronunciation parameter, not the contents of the textToSpeak parameter.

提示中指定內嵌的發音僅適用于個別出現的單字, 並覆寫語音引擎或其目前作用中字典的發音。Pronunciations specified inline in prompts apply only to the individual occurrence of a word and override pronunciations of the speech engine or any of its currently active lexicons. 一般來說, 您會將內嵌發音用於現有單字的自訂發音, 或用於不常用單字的發音, 例如適當的名稱, 語音合成引擎可能不會如預期般地發音。Typically, you will use inline pronunciations for custom pronunciations of existing words or for pronunciation of uncommon words, such as proper names, which the speech synthesis engine may not pronounce as well as expected.

內嵌發音必須使用國際語音字母 (.IPA) 中的電話來指定。Inline pronunciations must be specified using phones from the International Phonetic Alphabet (IPA). 電話是代表語音聲音的字母或字元。A phone is a letter or character that represents a discreet sound of speech. 符合語音合成標記語言 (SSML) 版本 1.0規格的語音引擎將會從 .ipa 中發音。Speech engines that comply with the Speech Synthesis Markup Language (SSML) Version 1.0 specification will pronounce phones from the IPA. 若要指定使用其他語音字母的內嵌發音AppendSsmlMarkup, 請參閱。To specify inline pronunciations using other phonetic alphabets, see AppendSsmlMarkup.

.IPA 會發佈列出電話的圖表, 並將它們對應到 Unicode 數位。The IPA publishes a chart that lists its phones and maps them to Unicode numbers.

.IPA 字母表中的某些手機與拉丁字母中的字母具有相同的標記法。Some phones in the IPA alphabet have the same representations as letters in the Latin alphabet. 在這些情況下, 可以輸入拉丁字元, 並具有正確的電話標記法。In those cases, it is possible to type the Latin character and have the proper representation for a phone. 因為文字中常用的拉丁字元可能代表 .IPA 電話集的數個電話, 所以只要輸入拉丁字元可能不會產生精確的 .IPA 電話。Because the Latin characters as commonly used in text may represent several phones of the IPA phone set, simply typing the Latin character might not result in the precise IPA phone desired. .IPA 字母的其他手機必須在程式碼中表示為字元參考, 其中包含連字號 (&)、數位記號 (#), 以及所需電話的 Unicode 數位 (十六進位或十進位), 後面接著分號 (;)。Other phones of the IPA alphabet need to be represented in code as character references consisting of an ampersand (&), the number sign (#), and a Unicode number for the desired phone in hexadecimal or decimal, all followed by a semicolon (;). 例如, schwa (&#x0259;)會以表示&#x0259;For example, a schwa (&#x0259;) would be represented by &#x0259;.

若要為多個單字加入新的或自訂的發音, 例如, 若要表示區域方言, 或加入教育或醫療專業領域專屬的適當名稱或詞彙, 請建立字典, SpeechSynthesizerAddLexicon使用將其新增至。To add new or custom pronunciations for multiple words, for example to express regional dialects or to add proper names or vocabulary that is specific to an educational or medical discipline, build a lexicon and add it to the SpeechSynthesizer using AddLexicon.

適用於

另請參閱