
Kokoro TTS
CLI基于开源 Kokoro 模型的本地语音合成命令行工具,能把 TXT、EPUB、PDF 按章节批量转成 MP3 或 WAV,支持中文、音色混合和调速,适合老师做听力材料、把讲义转成有声版。需要 Python 3.11–3.12,并先下载两个模型文件。
Kokoro TTS
A CLI text-to-speech tool using the Kokoro model, supporting multiple languages, voices (with blending), and various input formats including EPUB books and PDF documents.

Features
- Multiple language and voice support
- Voice blending with customizable weights
- EPUB, PDF and TXT file input support
- Standard input (stdin) and
|piping from other programs - Streaming audio playback
- Split output into chapters
- Adjustable speech speed
- WAV and MP3 output formats
- Chapter merging capability
- Detailed debug output option
- GPU Support
Demo
Kokoro TTS is an open-source CLI tool that delivers high-quality text-to-speech right from your terminal. Think of it as your personal voice studio, capable of transforming any text into natural-sounding speech with minimal effort.
https://github.com/user-attachments/assets/8413e640-59e9-490e-861d-49187e967526
Demo Audio (MP3) | Demo Audio (WAV)
TODO
- Add GPU support
- Add PDF support
- Add GUI
Prerequisites
- Python 3.11-3.12 (Python 3.13+ is not currently supported)
Installation
Method 1: Install from PyPI (Recommended)
The easiest way to install Kokoro TTS is from PyPI:
# Using uv (recommended)
uv tool install kokoro-tts
# Using pip
pip install kokoro-tts
After installation, you can run:
kokoro-tts --help
Method 2: Install from Git
Install directly from the repository:
# Using uv (recommended)
uv tool install git+https://github.com/nazdridoy/kokoro-tts
# Using pip
pip install git+https://github.com/nazdridoy/kokoro-tts
Method 3: Clone and Install Locally
- Clone the repository:
git clone https://github.com/nazdridoy/kokoro-tts.git
cd kokoro-tts
- Install the package:
With uv (recommended):
uv venv
uv pip install -e .
With pip:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .
- Run the tool:
# If using uv
uv run kokoro-tts --help
# If using pip with activated venv
kokoro-tts --help
Method 4: Run Without Installation
If you prefer to run without installing:
- Clone the repository:
git clone https://github.com/nazdridoy/kokoro-tts.git
cd kokoro-tts
- Install dependencies only:
With uv:
uv venv
uv sync
With pip:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
- Run directly:
# With uv
uv run -m kokoro_tts --help
# With pip (venv activated)
python -m kokoro_tts --help
Download Model Files
After installation, download the required model files to your working directory:
# Download voice data (bin format is preferred)
wget https://github.com/nazdridoy/kokoro-tts/releases/download/v1.0.0/voices-v1.0.bin
# Download the model
wget https://github.com/nazdridoy/kokoro-tts/releases/download/v1.0.0/kokoro-v1.0.onnx
The script requires
voices-v1.0.binandkokoro-v1.0.onnxto be present in the same directory where you run thekokoro-ttscommand.
Supported voices:
| Category | Voices | Language Code |
|---|---|---|
| 🇺🇸 👩 | af_alloy, af_aoede, af_bella, af_heart, af_jessica, af_kore, af_nicole, af_nova, af_river, af_sarah, af_sky | en-us |
| 🇺🇸 👨 | am_adam, am_echo, am_eric, am_fenrir, am_liam, am_michael, am_onyx, am_puck | en-us |
| 🇬🇧 | bf_alice, bf_emma, bf_isabella, bf_lily, bm_daniel, bm_fable, bm_george, bm_lewis | en-gb |
| 🇫🇷 | ff_siwis | fr-fr |
| 🇮🇹 | if_sara, im_nicola | it |
| 🇯🇵 | jf_alpha, jf_gongitsune, jf_nezumi, jf_tebukuro, jm_kumo | ja |
| 🇨🇳 | zf_xiaobei, zf_xiaoni, zf_xiaoxiao, zf_xiaoyi, zm_yunjian, zm_yunxi, zm_yunxia, zm_yunyang | cmn |
Usage
Basic Usage
kokoro-tts <input_text_file> [<output_audio_file>] [options]
[!NOTE]
- If you installed via Method 1 (PyPI) or Method 2 (git install), use
kokoro-ttsdirectly- If you installed via Method 3 (local install), use
uv run kokoro-ttsor activate your virtual environment first- If you're using Method 4 (no install), use
uv run -m kokoro_ttsorpython -m kokoro_ttswith activated venv
Commands
-h, --help: Show help message--help-languages: List supported languages--help-voices: List available voices--merge-chunks: Merge existing chunks into chapter files
Options
--stream: Stream audio instead of saving to file--speed <float>: Set speech speed (default: 1.0)--lang <str>: Set language (default: en-us)--voice <str>: Set voice or blend voices (default: interactive selection)- Single voice: Use voice name (e.g., "af_sarah")
- Blended voices: Use "voice1:weight,voice2:weight" format
--split-output <dir>: Save each chunk as separate file in directory--format <str>: Audio format: wav or mp3 (default: wav)--debug: Show detailed debug information during processing
Input Formats
.txt: Text file input.epub: EPUB book input (will process chapters).pdf: PDF document input (extracts chapters from TOC or content)-or/dev/stdin(Linux/macOS) orCONIN$(Windows): Standard input (stdin)
Examples
# Basic usage with output file
kokoro-tts input.txt output.wav --speed 1.2 --lang en-us --voice af_sarah
# Read from standard input (stdin)
echo "Hello World" | kokoro-tts - --stream
cat input.txt | kokoro-tts - output.wav
# Cross-platform stdin support:
# Linux/macOS: echo "text" | kokoro-tts - --stream
# Windows: echo "text" | kokoro-tts - --stream
# All platforms also support: kokoro-tts /dev/stdin --stream (Linux/macOS) or kokoro-tts CONIN$ --stream (Windows)
# Use voice blending (60-40 mix)
kokoro-tts input.txt output.wav --voice "af_sarah:60,am_adam:40"
# Use equal voice blend (50-50)
kokoro-tts input.txt --stream --voice "am_adam,af_sarah"
# Process EPUB and split into chunks
kokoro-tts input.epub --split-output ./chunks/ --format mp3
# Stream audio directly
kokoro-tts input.txt --stream --speed 0.8
# Merge existing chunks
kokoro-tts --merge-chunks --split-output ./chunks/ --format wav
# Process EPUB with detailed debug output
kokoro-tts input.epub --split-output ./chunks/ --debug
# Process PDF and split into chapters
kokoro-tts input.pdf --split-output ./chunks/ --format mp3
# List available voices
kokoro-tts --help-voices
# List supported languages
kokoro-tts --help-languages
[!TIP] If you're using Method 3, replace
kokoro-ttswithuv run kokoro-ttsin the examples above. If you're using Method 4, replacekokoro-ttswithuv run -m kokoro_ttsorpython -m kokoro_ttsin the examples above.
Features in Detail
EPUB Processing
- Automatically extracts chapters from EPUB files
- Preserves chapter titles and structure
- Creates organized output for each chapter
- Detailed debug output available for troubleshooting
Audio Processing
- Chunks long text into manageable segments
- Supports streaming for immediate playback
- Voice blending with customizable mix ratios
- Progress indicators for long processes
- Handles interruptions gracefully
Output Options
- Single file output
- Split output with chapter organization
- Chunk merging capability
- Multiple audio format support
Debug Mode
- Shows detailed information about file processing
- Displays NCX parsing details for EPUB files
- Lists all found chapters and their metadata
- Helps troubleshoot processing issues
Input Options
- Text file input (.txt)
- EPUB book input (.epub)
- Standard input (stdin)
- Supports piping from other programs
Contributing
This is a personal project. But if you want to contribute, please feel free to submit a Pull Request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
相關資源

Podcastfy
CLI开源的 NotebookLM 播客功能替代品,把网页、PDF、图片、YouTube 视频或文字转成两人对话式播客音频,适合老师把讲义、作者把文章做成音频节目。默认需要 Gemini 与 OpenAI API Key,也可用本地模型加免费的 Edge 语音。
souzatharsis/podcastfy6.9k
Piper
CLI本地运行的神经网络语音合成引擎,离线把文字转成语音,支持中文在内的数十种语言音色,适合老师制作听力材料、给文章或课件配旁白。需要 Python,首次使用要先下载对应音色模型;项目目前在招募维护者。
OHF-Voice/piper1-gpl6.5k
MulmoCast CLI
CLI用 JSON/YAML 格式的 MulmoScript 写好讲稿、说话人与画面,mulmo 命令即可生成配音和插图,合成为视频、播客、幻灯片或 PDF,可把讲义、报告做成讲解视频。需要 Node.js、FFmpeg 和 OpenAI API Key,其他厂商的 Key 可选。
receptron/mulmocast-cli482
Web Video Presentation
Skill把文章或讲稿改写成口播稿,再做成点击推进的 16:9 网页演示,录屏即可得到讲解视频,可选合成配音,适合教师录课、B 站/YouTube 教程和产品讲解。需要 Node.js 环境;配音需 MiniMax 或 OpenAI 的 API Key,也可换成其他 TTS。
ConardLi/garden-skills16.1k
anything2explainer
Skill输入一个主题或一篇文章,自动调研、写解说词、配音、分镜并逐镜做动画,产出带字幕、章节卡和进度条的中英文科普讲解视频,适合老师做课程视频。需要 Node.js、ffmpeg 与 Python 环境,中文默认用免费的 edge-tts 配音;按时长约需 1–3 小时;工具包仅限非商业免费使用,商用需作者授权。
Vincentwei1021/anything2explainer3.8k
BibiGPT Skill
SkillBibiGPT 官方技能:把 B 站、YouTube、播客或本地音视频交给 agent,生成摘要、带时间戳字幕、分章节要点和思维导图,适合听课复习和整理研究笔记。需要 BibiGPT 账号(免费用户每日次数和时长有限),并安装其桌面端(含 bibi 命令行)或配置 API Key。
JimmyLv/bibigpt-skill148