# Text-to-Speech

> The Text-to-Speech (TTS) is a technology that converts written text into spoken audio.

## What is text-to-speech (TTS)?

The technology that turns text into natural-sounding speech. Neural TTS can stream audio while the text is still being generated, so playback starts within a fraction of a second.

- Topic: Voice AI
- Type: technology

## Example

Wrong:

```js
const answer = await generateAnswer(question);
const audio = await synthesize(answer);
play(audio);
```

Right:

```js
for await (const sentence of streamSentences(question)) {
  const spoken = stripMarkdown(sentence);
  queueAudio(await synthesize(spoken));
}
```

Synthesizing sentence by sentence without Markdown starts playback sooner and avoids reading symbols aloud.

## Common mistakes

- Sending a full LLM answer with bullet points and links straight to TTS.

## Key points

- Audio is streamed and played in chunks instead of waiting for the full file.
- Text sent to TTS has no Markdown or code symbols that would be read aloud.

## Interview questions

### What is SSML in text-to-speech?

SSML is an XML markup language for speech that controls pauses, emphasis, pronunciation and speed. Support for its tags differs between TTS engines.

### How do I make TTS pronounce a word correctly?

Use a pronunciation dictionary or SSML phoneme tags if the engine supports them, or rewrite the word in the text the way it should sound.

### Why does my TTS read symbols like asterisks out loud?

The text still contains Markdown or code. Strip formatting or ask the model to answer in plain spoken sentences before sending text to TTS.

## Related cards

- [Speech-to-Text](https://wonderium.dev/ai/speech-to-text.md)
- [speechSynthesis](https://wonderium.dev/js/speech-synthesis.md)
- [Voice Agent](https://wonderium.dev/ai/voice-agent.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/text-to-speech
- Last updated: 2026-11-25
