Prompt

How do I generate speech with SSML tags in an API?

Artificial Intelligence / Speech & Voice AI2 observationsLast seen Nov 12, 2026

Latest observation

Nov 12, 2026OpenAI APIWeb search: off

To generate speech with SSML in a text-to-speech API, you typically:

  1. Wrap your spoken text in SSML
  2. Send it to the TTS endpoint with the correct content type / input type
  3. Choose a voice and output format
  4. Read back the audio response

What SSML is

SSML (Speech Synthesis Markup Language) lets you control pronunciation, pauses, emphasis, speaking rate, pitch, etc.

Example:

<speak>
  Hello there.
  <break time="500ms"/>
  <emphasis level="strong">Welcome</emphasis> to our service.
</speak>

Typical API flow

Most TTS APIs expect:

  • plain text or SSML
  • a voice name
  • an audio output format like MP3 or WAV

Example request body

{
  "input": {
    "ssml": "<speak>Hello <break time='300ms'/> world.</speak>"
  },
  "voice": {
    "languageCode": "en-US",
    "name": "en-US-Neural2-J"
  },
  "audioConfig": {
    "audioEncoding": "MP3"
  }
}

cURL example

curl -X POST "https://api.example.com/tts" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "input": {
      "ssml": "<speak>Hello <break time=\"300ms\"/> world.</speak>"
    },
    "voice": {
      "languageCode": "en-US",
      "name": "en-US-Neural2-J"
    },
    "audioConfig": {
      "audioEncoding": "MP3"
    }
  }'

Important SSML rules

  • Your SSML must usually be wrapped in <speak>...</speak>
  • Escape quotes properly in JSON
  • Not all SSML tags are supported by every provider
  • Some APIs require SSML to be sent in a dedicated field like ssml, while others use a generic text field plus a flag like textType: "ssml"

Common SSML tags

  • <break time="500ms"/> — pause
  • <emphasis> — stress words
  • <prosody rate="slow" pitch="+2st"> — control speech rate/pitch
  • <say-as interpret-as="characters">API</say-as> — spell out text
  • <sub alias="World Wide Web Consortium">W3C</sub> — alternate pronunciation

Example:

<speak>
  Please call <say-as interpret-as="characters">AI</say-as>.
  <break time="250ms"/>
  This is <prosody rate="slow">slower speech</prosody>.
</speak>

If you’re using a specific provider

The exact request format depends on the API:

  • Google Cloud Text-to-Speech
  • Amazon Polly
  • Azure Speech
  • OpenAI-compatible TTS
  • others

If you tell me which API/provider you’re using and your language (Python, Node.js, cURL, etc.), I can give you the exact working example.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.