Text-to-speech (TTS) converts written text into spoken audio — the output side of a voice pipeline, with its own real considerations around latency, naturalness, and cost.
Basic Usage (Conceptual)
# Conceptual — real syntax differs by provider
audio = tts_client.synthesize(
text="Your order has shipped and will arrive in 3 days.",
voice="voice-name"
)
save_audio(audio, "response.mp3")
Streaming TTS for Perceived Latency
Similar to text streaming (see Streaming), many TTS services support streaming audio output — starting playback before the entire audio is generated, improving perceived responsiveness in real-time voice applications, the same way text streaming improves perceived chat responsiveness.
Practical Considerations
| Consideration | Why It Matters |
|---|---|
| Voice selection | Different voices/tones may suit different brand identities or use cases — often configurable |
| Latency | Generation time adds to a voice pipeline's total response time — streaming helps perceived latency |
| Cost | Typically priced per character/token of input text — relevant at scale, similar to LLM token cost considerations |
| Pronunciation of domain-specific terms | Product names, technical terms, or abbreviations may need special handling (phonetic hints, if supported) to sound correct |
Text Preparation Before TTS
Raw text: "Order #4521 - ETA: 3-5 business days"
Better for TTS: "Order number 4521. Estimated arrival: 3 to 5
business days."
→ Abbreviations, symbols, and number formats that read fine as
text can sound awkward or be mispronounced when synthesized
directly — worth normalizing text specifically for speech
output.
Practical Use Case
A voice assistant reading order confirmations, appointment reminders, or notifications benefits from text specifically written/formatted for how it will sound spoken aloud — text that reads naturally on a screen doesn't always sound natural when synthesized.
Common Mistakes
- Sending raw application text (with abbreviations, symbols, unusual formatting) directly to TTS without normalizing it for speech
- Not using streaming TTS for real-time interactive applications, adding unnecessary perceived latency
- Not testing how domain-specific terms (product names, technical jargon) actually sound when synthesized before shipping to users
Interview Relevance
"Why might text that reads perfectly fine sound wrong when converted to speech?" — abbreviations, symbols, and formatting conventions common in written text often need normalization for natural-sounding speech output.
Practice Question
Rewrite "Your total is $45.99, tax incl. Order #A-4521" into text better suited for text-to-speech synthesis.