# Text to speech with AI: make a voice that sounds natural

> Text to speech turns written text into spoken audio. OpenAI's speech endpoint takes a model, your text and a voice, plus an instructions field that sets tone, pace and accent, and open models such as Kokoro run on your own computer. A natural result comes from a well-chosen voice, clear direction and a check on how names and numbers are read.

Mindket editors · Published 2026-11-06 · Updated 2026-11-06 · https://mindket.com/learn/ai-voice-music/text-to-speech

## In short

- Send one request to a speech endpoint and save the answer as an audio file.
- Write a short direction for tone, pace and accent, and change one thing per try.
- Spell out names, acronyms and codes the way they should be said.
- Pick the route that fits the job: a hosted API, or a model on your own computer.
- Tell listeners when a voice is AI-generated.

## Before you start

**Text to speech** (TTS) means a program reads written text aloud in a synthetic voice. This lesson covers two routes. The first calls OpenAI's speech endpoint, which needs an API key and a terminal with `curl`, and the [OpenAI API quickstart](https://mindket.com/learn/openai-api/openai-api-quickstart) shows how to get a key. The second runs Kokoro, a small open model, with Python on your own computer.

One date shapes the first route. OpenAI's guide marks `tts-1`, `tts-1-hd` and `gpt-4o-mini-tts` as deprecated, with a shutdown on 6 January 2027, and points new work to `gpt-realtime-2.1-mini` through the Realtime API. That is a different workflow, and the page says the model is not supported on `/v1/audio/speech`. Until the shutdown, the Speech API examples keep working, and they teach what every route shares: a voice, a direction and an output format.

OpenAI's usage policies also ask you to tell listeners that the voice is AI-generated and not a human voice. Plan the spoken line or the caption for that now, since adding it later is easy to forget.

## Make a speech file with OpenAI's speech endpoint

The request has three required parts, the model, the text and the voice, and one optional part that matters here, `instructions`. The command below is the one from OpenAI's guide. It sends a sentence and a short direction, and writes the answer to `speech.mp3`.

````bash
curl https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "Today is a wonderful day to build something people love!",
    "voice": "coral",
    "instructions": "Speak in a cheerful and positive tone."
  }' \
  --output speech.mp3
````

1. Put your API key in the `OPENAI_API_KEY` environment variable.
2. Run the command above in a terminal. The guide's Python, JavaScript, Go, Java, C# and Ruby tabs send the same four fields.
3. Open `speech.mp3` and listen. MP3 is the default format.
4. Change `voice` to `marin` or `cedar`. The guide's voice list names 13 built-in voices (its introduction says 11) and recommends those two for the best quality.
5. Ask for `wav` or `pcm` with `response_format` when you stream the audio to speakers. The guide recommends them for the fastest response, and says pcm is raw 24 kHz, 16-bit samples with no header.
6. Change one field and run it again. A single change per try tells you which field did what.

| Output format | The guide says it is for |
| --- | --- |
| MP3 | General use, and the default |
| Opus | Internet streaming and communication, low latency |
| AAC | Digital audio compression, preferred by YouTube, Android and iOS |
| FLAC | Lossless compression, favored for archiving |
| WAV | Uncompressed audio for low-latency work that should skip decoding |
| PCM | Raw 24 kHz, 16-bit samples with no header |

## Direct the voice: tone, pace, accent and pronunciation

The `instructions` field takes plain language. OpenAI's guide says it can steer accent, emotional range, intonation, impressions, speed of speech, tone and whispering, and gives one line as its example. For longer directions, OpenAI's guide to prompting Realtime voice models writes them as short labelled sections. Those are written for Realtime models, so read them as wording to borrow, not as a promise for the speech endpoint.

The block below joins three of that guide's separate examples into one direction and leaves out its Length line, which is about turns in a conversation. The guide says to keep the pronunciation list short and to add a word when you hear it said wrong.

````text
# Personality & Tone
## Personality
- Friendly, calm and approachable expert customer service assistant.
## Tone
- Warm, concise, confident, never fawning.
## Pacing
- Deliver your audio response fast, but do not sound rushed.
- Do not modify the content of your response, only increase speaking speed for the same response.

# Reference Pronunciations
When voicing these words, use the respective pronunciations:
- Pronounce “SQL” as “sequel.”
- Pronounce “PostgreSQL” as “post-gress.”
- Pronounce “Kyiv” as “KEE-iv.”
- Pronounce "Huawei" as “HWAH-way”
````

- **Pace.** In the Realtime API the `speed` setting changes playback rate, not how the model composes speech. To sound faster, the guide adds a pacing instruction like the one above.
- **Accent.** The guide says a vague line such as "Sound Australian." can drift or switch language. It writes the accent as a few stable traits: "Speak English with a light Australian accent", keep it stable from the first word to the last, do not exaggerate it.
- **Codes and numbers.** For phone numbers, order IDs and codes, the guide adds: speak each character separately, separated by hyphens (for example 4-1-5), and repeat the number exactly.
- **Limits of direction.** The guide says prompting steers accent, pacing and delivery but does not replace voice design. A branded voice calls for a custom voice, which [the next lesson](https://mindket.com/learn/ai-voice-music/voice-cloning) covers.
- **Repetition.** Sample phrases can be overused. A variety rule ("Do not repeat the same sentence twice") keeps a long read from sounding robotic.

| What sounds off | What to change |
| --- | --- |
| Flat, one-note delivery | Add tone and emotion words to `instructions`, such as "cheerful and positive" |
| Too slow or too fast | Say the pace in words, since the `speed` setting only changes playback in the Realtime API |
| A name or acronym said wrong | List how it should sound: "SQL" as "sequel" |
| Digits blur together | Ask for one character at a time, separated by hyphens |
| The accent wanders | Name the accent, say what stays stable and say not to exaggerate it |
| The same phrase keeps returning | Add a variety line |

## Watch OpenAI introduce the speech model

On 20 March 2025, four OpenAI team members introduced three audio models in the API, one of them the text to speech model behind the `instructions` field, and demonstrated it. The speech guide now lists that model as deprecated, so use the video for the idea of steering a voice and the guide for current dates.

[Audio Models in the API](https://www.youtube.com/watch?v=lXb0L16ISAc)

OpenAI introduces and demonstrates three new audio models in the API, streamed on 20 March 2025 on its own channel.

## Run an open model on your own computer: Kokoro

Kokoro is an open-weight model with 82 million parameters and a lightweight design. Its weights are Apache-licensed, so they can go into a product. The model card says it was trained only on permissive or non-copyrighted audio: public domain recordings, audio under licenses such as Apache or MIT, and synthetic audio from closed TTS models. Its README examples choose a named voice such as `af_heart` and show no reference clip. Version 1.0, published on 27 January 2025, ships 54 voices in 8 languages.

The package is `kokoro`. It also needs `espeak-ng`, a speech tool the README installs for English words outside its dictionary and for some other languages. The README's cell, trimmed below, writes one WAV file per chunk of text at 24,000 Hz.

````python
pip install -q "kokoro>=0.9.4" soundfile
# espeak-ng: on Linux  apt-get -qq -y install espeak-ng
#            on Windows  run the .msi from the espeak-ng releases page

from kokoro import KPipeline
import soundfile as sf

pipeline = KPipeline(lang_code='a')   # 'a' => American English
text = '''Kokoro is an open-weight TTS model with 82 million parameters.'''
generator = pipeline(text, voice='af_heart')
for i, (gs, ps, audio) in enumerate(generator):
    print(i, gs, ps)
    sf.write(f'{i}.wav', audio, 24000)
````

- `lang_code` picks the language and must match the voice: `a` American English, `b` British English, `e` Spanish, `f` French, `h` Hindi, `i` Italian, `j` Japanese, `p` Brazilian Portuguese, `z` Mandarin Chinese.
- Japanese needs `pip install misaki[ja]` and Mandarin needs `pip install misaki[zh]`.
- On a Mac with Apple Silicon, the README sets `PYTORCH_ENABLE_MPS_FALLBACK=1` to get GPU acceleration.
- The model card links the full voice list (VOICES.md) and audio samples (SAMPLES.md).
- The card warns that sites with kokoro in their domain name, such as kokorottsai_com, are not affiliated with the model and are likely scams.

## Which route fits the job

A hosted API gives you direction in plain words and a finished voice. Kokoro costs nothing per file and keeps text on your machine, but you choose from its voices. Chatterbox takes a reference clip and has expression controls, with a catch in its status. For hosted tools beyond OpenAI, the [AI voice generator lesson](https://mindket.com/learn/ai-tools/best-ai-voice-generator) compares them.

**Three ways to turn text into speech**

| | OpenAI speech endpoint | Kokoro-82M | Chatterbox |
| --- | --- | --- | --- |
| Runs on your own computer | ✗ No | ✓ Yes | ✓ Yes |
| Tone and pace set in plain words | ✓ Yes | Not shown in its README | ◐ Partly |
| Clones a voice from a clip | ◐ Partly | Not shown in its README | ✓ Yes |
| Languages | Follows Whisper's list, voices tuned for English | 8 languages, 54 voices | 23+ with Multilingual V3, English only for Turbo and Nano |
| License or terms | OpenAI usage policies | Apache-2.0 | MIT |
| Status on 6 November 2026 | Speech models shut down 6 January 2027 | Version 1.0 from January 2025 | Retired in August 2026, kept as an archive |

Sources: [OpenAI API docs: Text to speech](https://developers.openai.com/api/docs/guides/text-to-speech) (read 2026-11-06), [Hugging Face: hexgrad/Kokoro-82M model card](https://huggingface.co/hexgrad/Kokoro-82M) (read 2026-11-06), [GitHub: resemble-ai/chatterbox README](https://github.com/resemble-ai/chatterbox) (read 2026-11-06), [Hugging Face: ResembleAI/chatterbox model card](https://huggingface.co/ResembleAI/chatterbox) (read 2026-11-06)

## Dates that decide what you build on

Four dates from the vendors' own pages. The transcription shutdown matters again in the dubbing lesson, which starts from speech and ends in speech.

1. **January 27, 2025** Kokoro version 1.0 published. 54 voices in 8 languages, Apache-licensed weights.
2. **August 2026** Chatterbox retired. The repository stays public as an archive under the MIT license, with no support or updates.
3. **January 6, 2027** OpenAI speech models shut down. `tts-1`, `tts-1-hd` and `gpt-4o-mini-tts` stop working. Migrate to the Realtime API.
4. **February 26, 2027** OpenAI transcription models shut down. `whisper-1`, the `gpt-4o-transcribe` models and `/v1/audio/translations` stop working.

Sources: [Hugging Face: hexgrad/Kokoro-82M model card](https://huggingface.co/hexgrad/Kokoro-82M) (read 2026-11-06), [GitHub: resemble-ai/chatterbox README](https://github.com/resemble-ai/chatterbox) (read 2026-11-06), [OpenAI API docs: Text to speech](https://developers.openai.com/api/docs/guides/text-to-speech) (read 2026-11-06), [OpenAI API docs: File transcription](https://developers.openai.com/api/docs/guides/speech-to-text) (read 2026-11-06)

## Common mistakes

- Starting a new product on `gpt-4o-mini-tts` with no plan for its shutdown date.
- Asking for "an Australian accent" with nothing about what should stay stable, then hearing it drift.
- Using the `speed` setting to change how a line is delivered, when it only changes playback in the Realtime API.
- Letting a phone number or order ID run together instead of asking for one character at a time.
- Using a Kokoro `lang_code` that does not match the voice, or leaving out `espeak-ng`.
- Piling pronunciations into one long list, when the guide says to keep it short and add words as you hear them wrong.
- Leaving out the line that tells listeners the voice is AI-generated.

## Try it yourself

- Make `speech.mp3` with the request above, then change only `voice` to `marin` and compare the two files.
- Write a direction for one paragraph of your own, with a pace line and the pronunciation of one name, and check that the name comes out right.
- Read a made-up order ID once with no rule and once with the hyphen rule, and listen for the difference.
- Run the Kokoro cell, then switch `lang_code` and `voice` together to another language the README lists.

## Next lesson: voice cloning

Choosing a built-in voice is one thing. Making a voice that sounds like a specific person is another, and it comes with consent rules. [Voice cloning](https://mindket.com/learn/ai-voice-music/voice-cloning) covers how it works, what OpenAI and the open models ask of you and what to check before you clone anything.

## Check yourself

1. Which field of OpenAI's speech request sets tone, pace and accent in plain words?

   A. input
   B. voice
   C. instructions
   D. response_format

   Answer: C. The guide says instructions steers accent, emotional range, intonation, speed of speech, tone and whispering. The other fields set the text, the voice and the file format.

2. When does the guide say tts-1, tts-1-hd and gpt-4o-mini-tts shut down?

   A. 26 February 2027
   B. 6 January 2027
   C. They already have
   D. 1 December 2026

   Answer: B. The guide marks the three models deprecated and gives 6 January 2027 as the shutdown date. 26 February 2027 is the date for the transcription models.

3. Which of these does the Kokoro model card state?

   A. It runs only through a hosted API
   B. It speaks English only
   C. It has 8.2 billion parameters
   D. It has 82 million parameters and Apache-licensed weights

   Answer: D. The card calls Kokoro an open-weight model with 82 million parameters and Apache-licensed weights. Version 1.0 lists 54 voices in 8 languages, and the pip package runs on your own computer.

4. A phone number is read as one blur of digits. What does OpenAI's Realtime prompting guide suggest?

   A. Ask for one character at a time, separated by hyphens
   B. Raise the speed setting
   C. Switch the output format to wav
   D. Use a longer voice sample

   Answer: A. The guide adds a rule to speak each character separately, separated by hyphens, and to repeat the number exactly.

## Frequently asked questions

### Can the speech endpoint play audio while it is still being made?

Yes. The guide says the endpoint streams audio with chunk transfer encoding, so playback can begin before the whole file exists. For the fastest start it recommends wav or pcm as the format.

### Is there a free text to speech AI that runs offline?

Kokoro is one. It installs with pip and espeak-ng, runs on your own computer and picks from 54 voices. Its card says the weights are Apache-licensed, and its README examples pick a named voice.

### Do I have to say a voice is AI-generated?

For OpenAI's voices, yes, because its usage policies call for a clear notice to the people listening. A line in the caption or description is the simplest place for it. Other tools set their own terms, so read each one.

### Which languages can OpenAI text to speech speak?

The guide says the model generally follows Whisper's language list, which includes Chinese, Spanish, French, Hindi and Malay, and that the voices are optimized for English. You write the input text in the language you want.

### How do I make text to speech sound less robotic?

Direct it in words: tone and pace, a stable accent, a short list of pronunciations and one character at a time for codes. Change one thing per try, since several changes at once hide which one helped.

## Sources

- [OpenAI API docs: Text to speech](https://developers.openai.com/api/docs/guides/text-to-speech) (read 2026-11-06)
- [OpenAI API docs: Prompting Realtime models](https://developers.openai.com/api/docs/guides/voice-prompting) (read 2026-11-06)
- [OpenAI API docs: File transcription](https://developers.openai.com/api/docs/guides/speech-to-text) (read 2026-11-06)
- [Hugging Face: hexgrad/Kokoro-82M model card](https://huggingface.co/hexgrad/Kokoro-82M) (read 2026-11-06)
- [GitHub: hexgrad/kokoro README](https://github.com/hexgrad/kokoro) (read 2026-11-06)
- [GitHub: resemble-ai/chatterbox README](https://github.com/resemble-ai/chatterbox) (read 2026-11-06)
- [Hugging Face: ResembleAI/chatterbox model card](https://huggingface.co/ResembleAI/chatterbox) (read 2026-11-06)
- [YouTube: OpenAI, Audio Models in the API](https://www.youtube.com/watch?v=lXb0L16ISAc) (read 2026-11-06)

[Compare voice tools](https://mindket.com/learn/ai-tools/best-ai-voice-generator)
