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 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.
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- Put your API key in the
OPENAI_API_KEYenvironment variable. - Run the command above in a terminal. The guide's Python, JavaScript, Go, Java, C# and Ruby tabs send the same four fields.
- Open
speech.mp3and listen. MP3 is the default format. - Change
voicetomarinorcedar. The guide's voice list names 13 built-in voices (its introduction says 11) and recommends those two for the best quality. - Ask for
wavorpcmwithresponse_formatwhen 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. - 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.
# 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
speedsetting 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 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.

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.
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_codepicks the language and must match the voice:aAmerican English,bBritish English,eSpanish,fFrench,hHindi,iItalian,jJapanese,pBrazilian Portuguese,zMandarin Chinese.- Japanese needs
pip install misaki[ja]and Mandarin needspip install misaki[zh]. - On a Mac with Apple Silicon, the README sets
PYTORCH_ENABLE_MPS_FALLBACK=1to 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 compares them.
| 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 (read November 6, 2026), Hugging Face: hexgrad/Kokoro-82M model card (read November 6, 2026), GitHub: resemble-ai/chatterbox README (read November 6, 2026), Hugging Face: ResembleAI/chatterbox model card (read November 6, 2026)
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.
Kokoro version 1.0 published
54 voices in 8 languages, Apache-licensed weights.
Source: Hugging Face: hexgrad/Kokoro-82M model card (read November 6, 2026)
Chatterbox retired
The repository stays public as an archive under the MIT license, with no support or updates.
Source: GitHub: resemble-ai/chatterbox README (read November 6, 2026)
OpenAI speech models shut down
tts-1,tts-1-hdandgpt-4o-mini-ttsstop working. Migrate to the Realtime API.Source: OpenAI API docs: Text to speech (read November 6, 2026)
OpenAI transcription models shut down
whisper-1, thegpt-4o-transcribemodels and/v1/audio/translationsstop working.Source: OpenAI API docs: File transcription (read November 6, 2026)
Common mistakes
- Starting a new product on
gpt-4o-mini-ttswith no plan for its shutdown date. - Asking for "an Australian accent" with nothing about what should stay stable, then hearing it drift.
- Using the
speedsetting 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_codethat does not match the voice, or leaving outespeak-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.mp3with the request above, then change onlyvoicetomarinand 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_codeandvoicetogether 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 covers how it works, what OpenAI and the open models ask of you and what to check before you clone anything.
Check yourself
Which field of OpenAI's speech request sets tone, pace and accent in plain words?
Show answer
C. instructions 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.
When does the guide say tts-1, tts-1-hd and gpt-4o-mini-tts shut down?
Show answer
B. 6 January 2027 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.
Which of these does the Kokoro model card state?
Show answer
D. It has 82 million parameters and Apache-licensed weights 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.
A phone number is read as one blur of digits. What does OpenAI's Realtime prompting guide suggest?
Show answer
A. Ask for one character at a time, separated by hyphens 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
- OpenAI API docs: Prompting Realtime models https://developers.openai.com/api/docs/guides/voice-prompting
- OpenAI API docs: File transcription https://developers.openai.com/api/docs/guides/speech-to-text
- Hugging Face: hexgrad/Kokoro-82M model card https://huggingface.co/hexgrad/Kokoro-82M
- GitHub: hexgrad/kokoro README https://github.com/hexgrad/kokoro
- GitHub: resemble-ai/chatterbox README https://github.com/resemble-ai/chatterbox
- Hugging Face: ResembleAI/chatterbox model card https://huggingface.co/ResembleAI/chatterbox
- YouTube: OpenAI, Audio Models in the API https://www.youtube.com/watch?v=lXb0L16ISAc
