BroadRouter

Text-to-speech (TTS)

Updated

Text-to-speech (TTS), or speech synthesis, converts written text into spoken audio. A TTS API takes text, a voice and an output format such as MP3 or WAV, and returns generated speech. It is the reverse of speech-to-text, which turns audio into text.

Also called: TTS, text to speech, speech synthesis

Speech-to-text listens. Text-to-speech talks back. Voice assistants need both.

How it works

A TTS API takes three things: the text, a voice, and an audio format. This is the shape of the Python example in OpenAI’s guide:

from openai import OpenAI
client = OpenAI()
with client.audio.speech.with_streaming_response.create(
    model="gpt-4o-mini-tts",
    voice="coral",
    input="Today is a wonderful day to build something people love!",
    instructions="Speak in a cheerful and positive tone.",
) as response:
    response.stream_to_file("speech.mp3")

Its guide documents the /v1/audio/speech endpoint, 13 built-in voices, and output formats MP3 (default), Opus, AAC, FLAC, WAV and PCM, where PCM is raw 24 kHz 16-bit samples with no header. It supports streaming with chunked transfer encoding, so playback can start before the file is finished, and recommends WAV or PCM for the fastest responses. The guide also marks tts-1, tts-1-hd and gpt-4o-mini-tts as deprecated, with shutdown on 6 January 2027. Check the current model list before you build on one.

Many engines also accept SSML, the W3C’s XML markup for synthesis. The root <speak> element declares version="1.1" and xml:lang. Other elements include <break> for pauses, <say-as> to mark dates or numbers, <phoneme> for an exact pronunciation (for example in IPA) and <lang> for a phrase in another language:

<speak version="1.1" xml:lang="en-US">
  Pasta should be cooked <lang xml:lang="it">al dente</lang>.
  <break/> Enjoy your meal.
</speak>

Why it matters

  • Voice products are pipelines. A voice bot is speech-to-text, then a chat model, then TTS. Each step adds latency and cost, and each can be a different provider.
  • Format choice. The output format decides size and playback support. WhatsApp, for example, plays Ogg Opus voice notes.
  • Disclosure. OpenAI requires telling end users that a TTS voice is AI-generated.

On BroadNet Inference

BroadNet does not offer text-to-speech. Its API reference documents only POST /v1/chat/completions and POST /v1/audio/transcriptions. It offers the other direction: BroadNet Transcribe Arabic and BroadNet Transcribe turn WAV or MP3 audio into text, at $0.0042 and $0.002 per minute. BroadNet also offers no live or real-time voice.

If your product must speak, pair BroadNet transcription and chat with a separate TTS provider. Text, speech and vision maps which jobs BroadNet covers and where you need another service, and the WhatsApp chatbot architecture post shows the voice-note side of the pipeline.

Common mistakes

  • Confusing TTS with STT. Speech-to-text APIs do not generate audio. Check the endpoint list, not just the word “speech”.
  • Assuming SSML works everywhere. Many APIs accept only plain text or a subset of SSML.

Questions

Does BroadNet Inference offer text-to-speech?

No. BroadNet documents two endpoints, chat completions and audio transcription. There is no /v1/audio/speech. Use a separate TTS provider if your app must speak.

What is SSML?

Speech Synthesis Markup Language, a W3C Recommendation (version 1.1, 2010). It is XML that controls pronunciation, pauses, pitch, rate and language switches in synthesized speech. Support varies by TTS provider.

Do I have to tell users a voice is AI-generated?

OpenAI's usage policies, as quoted in its TTS guide, require a clear disclosure that the voice is AI-generated. Check your own provider's terms and local law.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity