How does it turn text into a voice that sounds human?
Text-to-speech: phonemes, prosody and the waveform · Beginner · 5 min · tokens, transformer · after Speech-to-text: spectrograms and audio tokens (Whisper)
A text-to-speech model rewrites your text as sounds (phonemes), predicts how long each sound lasts and where the pitch goes, then writes the waveform: tens of thousands of numbers a second, almost none of them spelled out in the text.
1 Guess first
2 Look
From your text to a voice
1 / 4It’s raining.
↓ rewritten as sounds (IPA phonemes; ˈ marks the stressed syllable)
ɪts ɹˈeɪnɪŋ.
12 symbols → 14 numbers the model reads (one per symbol, plus a start and an end).
Measured with Kokoro-82M v1.0 (kokoro-js 1.2.1, eSpeak NG phonemes) · 2026-10-23
Spelling is not sound: the first step rewrites your text as phonemes, numbers and all.
The text only says which sounds to make. How long each one lasts, the melody and the voice are predicted by the model, then written out as 24,000 numbers a second.
Three things get added. First phonemes, the sounds a word is made of, because spelling is not sound. Then prosody, the timing and melody of speech. Then the voice. Kokoro learned prosody from a few hundred hours of recorded speech: it repeats patterns it heard, not grammar rules.
4 You are the model
You are the first step. For five bits of text, choose how each is said, then compare with the sounds Kokoro actually made.
you are the first step · turn the text into sounds · then see what Kokoro said
Dr. Lee lives on Main St.
How is “Dr.” said?
Measured with Kokoro-82M v1.0 (kokoro-js 1.2.1, eSpeak NG phonemes) · 2026-10-23
You are the first step. How should this be said?5 Check
It is speech-to-text in reverse. Whisper squeezes 16,000 numbers a second down to a few words; a voice model grows 13 characters into 37,200 numbers, and each added number is a guess learned from recordings. Kokoro is small: 82 million parameters. Commercial voices do not publish their size, so test them yourself.
7 Say it back
8 Mission · 5 min
On ElevenLabs’ free plan, generate “It’s raining.” and then “It’s raining?” with the same voice, and listen to the last word. Then generate “I read it yesterday.” Does the question rise, and do you hear “red” or “reed”?
Three quick ones
Drawn at random from this lesson's pool; different next time.
Done?
Go deeper
Sources
- Measured 2026-10-23 with scripts/explain-data/text-to-speech.ts: Kokoro-82M v1.0 (onnx-community/Kokoro-82M-v1.0-ONNX, fp32, CPU) through kokoro-js 1.2.1, voice af_heart unless named. “It’s raining.” → phonemes ɪts ɹˈeɪnɪŋ., 14 input ids, 37,200 samples (1.55 s at 24,000 Hz); “It’s raining?” 37,200; “Is it raining?” 39,000; speed 1.5 → 23,400; voice am_michael → 40,200
- Same run: pitch tracked by the script (normalised autocorrelation, one value every 10 ms): middle pitch 231 Hz (Heart), 128 Hz (Michael), 211 Hz (Heart at 1.5×); last voiced value 179 Hz for “It’s raining.” and 178 Hz for “It’s raining?”
- Same run, phonemes from kokoro-js’s normaliser and eSpeak NG: “Dr.” → dˈɑːktɚ, “$5.50” → fˈaɪv dˈɑːlɚz ænd fˈɪfti sˈɛnts, “1999” → nˈaɪntiːn nˈaɪndi nˈaɪn, “lives” (Dr. Lee lives on Main St.) → lˈaɪvz, “read” (I read it yesterday.) → ɹˈiːd, “10:30” → tˈɛn θˈɜːɾi; voice files 510 × 256 floats (522,240 bytes), one row of 256 used per input
- https://huggingface.co/hexgrad/Kokoro-82M (checked 2026-10-23): 82 million parameters, Apache-2.0, v1.0 of 2025-01-27 trained on a few hundred hours of permissive audio with IPA phoneme labels; architecture StyleTTS 2 and ISTFTNet; 24,000 Hz output
- https://arxiv.org/abs/2306.07691 (Li et al. 2023, StyleTTS 2): style diffusion and adversarial training; Whisper’s 16,000 Hz input from the speech-to-text lesson (openai/whisper audio.py SAMPLE_RATE 16000)
- aifree.dev catalog elevenlabs-free-plan (verified 2026-10-12) and /learn/free-text-to-speech-api (ElevenLabs pricing checked 2026-10-19): Free plan 10,000 credits a month, no card, Multilingual v2 1 credit per character; every provider in that guide meters text-to-speech by text length
Published Oct 23, 2026 · updated Oct 23, 2026