Kokoro TTS: I Generated High-Quality Voice Audio Locally in Python — Zero API Cost
ElevenLabs charges by the character. OpenAI TTS has a monthly cap. Kokoro-82M runs entirely on your machine, produces surprisingly natural-sounding audio, and costs exactly nothing. Here's how to set it up in Python in under 10 minutes.
The API Bill That Made Me Look for Alternatives
I was building a side project — a podcast-style digest that summarized my RSS feeds into audio every morning. Perfect use case for TTS. I hooked it up to ElevenLabs, set it running, and forgot about it for a week.
The bill was $47. For a side project that woke me up with news summaries. That's when I started looking for alternatives.
I tried every free tier I could find. OpenAI TTS caps out fast if you're generating long-form content. Google Cloud TTS has a free tier but the natural-sounding voices require the premium tier. Coqui-TTS is great but the setup is notoriously painful.
Then I found Kokoro-82M, and I haven't opened my ElevenLabs dashboard since.
What Is Kokoro-82M?
Kokoro is a hyper-fast, lightweight text-to-speech model with 82 million parameters. It was specifically designed to run efficiently on consumer hardware — no GPU required for reasonable generation speeds. The name "82M" refers to the parameter count, which puts it in a sweet spot: small enough to run locally, capable enough to sound genuinely good.
Key specs that matter for practical use:
- Runs fully offline — no internet connection needed after download
- Multiple voice styles (male, female, various accents)
- Generates audio faster than real-time on most modern CPUs
- Comes with a PySide6 GUI for non-developers
- Apache 2.0 license — free for commercial use
Setup: Python CLI in Under 10 Minutes
First, install the package and its dependencies:
pip install kokoro-onnx soundfile numpyDownload the model weights (one-time download, about 86MB):
from kokoro_onnx import KokoroTTS
# This downloads the model on first run
tts = KokoroTTS()Generate your first audio:
import soundfile as sf
text = "Hello! This is Kokoro running entirely on your local machine. No API keys, no billing, no rate limits."
# Generate audio
samples, sample_rate = tts.create(text, voice="af_heart", speed=1.0)
# Save as WAV
sf.write("output.wav", samples, sample_rate)
print("Audio saved to output.wav")That's it. Run the script. output.wav will appear in your directory. The first run takes 10–20 seconds to initialize the model; subsequent runs are instant.
Available Voices and Quality Comparison
Kokoro ships with several built-in voice models. The naming convention is country code + gender + style:
# American English voices
"af_heart" # Female, warm, natural
"af_bella" # Female, clear, neutral
"am_adam" # Male, deep
"am_michael" # Male, conversational
# British English voices
"bf_emma" # Female, British accent
"bm_george" # Male, British accentHonest quality assessment: Kokoro sounds noticeably better than older open-source TTS like Festival or eSpeak. It's competitive with ElevenLabs' standard voices but doesn't match their top-tier "eleven_turbo_v2" voice for pure naturalness. For podcast-style content, YouTube voiceovers, and app notifications, Kokoro is completely indistinguishable from paid services to most listeners.
Building a Real Use Case: Automated Audio Digest
Here's the script I actually use to generate my morning news digest:
from kokoro_onnx import KokoroTTS
import soundfile as sf
import numpy as np
tts = KokoroTTS()
def text_to_audio(text: str, output_file: str, voice: str = "af_heart"):
# Kokoro works best with chunks under 500 characters
chunks = [text[i:i+400] for i in range(0, len(text), 400)]
all_samples = []
for chunk in chunks:
samples, sr = tts.create(chunk, voice=voice, speed=1.05)
all_samples.append(samples)
combined = np.concatenate(all_samples)
sf.write(output_file, combined, sr)
print(f"Generated: {output_file}")
# Your content here
digest = "Good morning. Here are your top tech stories for today..."
text_to_audio(digest, "morning_digest.wav")This runs in a cron job every morning at 7am. I pair it with a Claude API call that summarizes my RSS feeds and passes the text here. Total cost of the whole pipeline: the Claude API call (fractions of a cent). The TTS is zero.
FAQ
Does Kokoro require a GPU?
No. Kokoro uses ONNX runtime which is optimized for CPU inference. On a modern laptop CPU, it generates audio faster than real-time. A GPU does speed things up for batch processing but is not required.
Can I use Kokoro for commercial projects?
Yes. Kokoro is licensed under Apache 2.0, which allows commercial use. Always check the model card for any specific voice restrictions, but the base model is fully commercially usable.
How does Kokoro compare to ElevenLabs for quality?
For standard narration at normal speaking speed, Kokoro produces audio that most non-technical listeners find indistinguishable from ElevenLabs standard voices. ElevenLabs has an edge in emotional range and voice cloning, but for straightforward TTS, Kokoro covers 90% of use cases at zero cost.
Explore RuView on GitHub
Browse the Rust engine, ESP32 firmware and examples.