Dela via


PromptBuilder.AppendTextWithPronunciation(String, String) Method

Definition

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)

Parameters

textToSpeak
String

A string containing the written form of the word using the conventional alphabet for a language.

pronunciation
String

A string containing phones to be spoken from the International Phonetic Alphabet (IPA).

Examples

The following example initializes a new instance of the PromptBuilder class. It then appends the text string "My name is" to the instance. 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ɑ");     
}  

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>  

Remarks

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.

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. Speech engines that comply with the Speech Synthesis Markup Language (SSML) Version 1.0 specification will pronounce phones from the IPA. To specify inline pronunciations using other phonetic alphabets, see AppendSsmlMarkup.

The IPA publishes a chart that lists its phones and maps them to Unicode numbers.

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. 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. 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 (;). For example, a schwa (&#x0259;) would be represented by &#x0259;.

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.

Applies to

See also