







You can use the AppendSsmlMarkup(String) method to append a string containing Speech Synthesis Markup Language (SSML) to a prompt. This topic shows simple examples that use a variety of SSML elements in prompts. For more information about SSML elements, see Speech Synthesis Markup Language Reference (Microsoft.Speech).
![]() |
---|
The string used as an argument to AppendSsmlMarkup(String) must not include a speak element. |
Add Emphasis to a Prompt
The emphasis element can be used to render speech at a higher stress level. For more information, see emphasis Element (Microsoft.Speech). The following example creates a prompt that, when played, renders the phrase "Normal speech" normally, and then renders the phrase "emphasized speech" in an emphasized fashion.
C# |
![]() |
---|---|
SpeechSynthesizer synth = new SpeechSynthesizer(); PromptBuilder pb1 = new PromptBuilder(); string str1 = "<emphasis> emphasized speech </emphasis>"; pb1.AppendText("Normal speech "); pb1.AppendSsmlMarkup(str1); synth.Speak(pb1); |
Append Audio to a Prompt
The audio element can be used to append audio to a prompt. In the following example, the synthesizer speaks "Subsitute text" if it cannot find or play the audio file. For more information, see audio Element (Microsoft.Speech).
C# |
![]() |
---|---|
SpeechSynthesizer synth = new SpeechSynthesizer(); PromptBuilder pb2 = new PromptBuilder(); string str2 = "<audio src = \"C:\\song.wav\"> Substitute text </audio>"; pb2.AppendText("And now a song: "); pb2.AppendSsmlMarkup(str2); synth.Speak(pb2); |
Append Substitute Text to a Prompt
The sub element can be used to provide alternate text to be rendered. In the following example, the synthesizer speaks "First in first out". For more information, see sub Element (Microsoft.Speech).
C# |
![]() |
---|---|
SpeechSynthesizer synth = new SpeechSynthesizer(); PromptBuilder pb3 = new PromptBuilder(); string str3 = "<sub alias=\"First in first out\"> F. I. F. O. </sub>"; pb3.AppendSsmlMarkup(str3); synth.Speak(pb3); |
Append Phonemes to a Prompt
The phoneme element can be used to render speech by its phonetic pronunciation. For more information, see phoneme Element (Microsoft.Speech). The following example creates a prompt that, when played, renders the Spanish word "llama" approximately as it would be spoken in Mexican Spanish.
C# |
![]() |
---|---|
SpeechSynthesizer synth = new SpeechSynthesizer(); PromptBuilder pb4 = new PromptBuilder(); string str4 = "<phoneme alphabet=\"x-microsoft-ups\" ph=\"J AA M AX\"> llama </phoneme>"; pb4.AppendSsmlMarkup(str4); synth.Speak(pb4); |