Prompt
How do I use SSML with a text-to-speech API?
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
SSML (Speech Synthesis Markup Language) lets you control how a text-to-speech engine speaks your text—things like pauses, emphasis, pronunciation, rate, pitch, and volume.
Basic idea
Instead of sending plain text, you send XML-like markup:
<speak>
Hello. <break time="500ms"/> How are you?
</speak>
The TTS API processes the SSML and generates speech accordingly.
Common SSML tags
These are widely supported, though exact support varies by provider:
<speak>: Root container for SSML<break time="..."/>: Pause<emphasis level="strong">...</emphasis>: Stress words<prosody rate="slow" pitch="+2st">...</prosody>: Change speaking style<say-as interpret-as="characters">TTS</say-as>: Spell out text<phoneme ph="...">...</phoneme>: Control pronunciation<sub alias="...">...</sub>: Replace spoken form<lang xml:lang="...">...</lang>: Switch language
Example
<speak>
<prosody rate="medium">
Welcome to our service.
</prosody>
<break time="300ms"/>
<emphasis level="moderate">Please</emphasis> review your settings.
Your order number is <say-as interpret-as="digits">12345</say-as>.
</speak>
Typical API usage
Most TTS APIs work like this:
- Choose a voice/model
- Mark the request as SSML or provide an SSML-specific field
- Send the SSML text
- Receive audio output
Example request body
{
"voice": "en-US-Standard-C",
"input_type": "ssml",
"text": "<speak>Hello <break time='300ms'/> world.</speak>"
}
Important notes
- Your SSML must be valid XML.
- Escape special characters like
&,<, and>when they appear in normal text. - Not every API supports every SSML tag.
- Some providers use slightly different syntax or have proprietary extensions.
Best practices
- Keep markup simple unless you need fine control.
- Test on your target voice/provider; SSML rendering can differ.
- Use pauses and emphasis sparingly so speech still sounds natural.
If you tell me which TTS provider you’re using (Google, AWS Polly, Azure, ElevenLabs, OpenAI, etc.), I can give you the exact SSML format and an example request.