epub2tts-kokoro is a free and open source python app to easily create a full-featured audiobook from an epub or text file using realistic text-to-speech using Kokoro.
- Creates standard format M4B audiobook file
- Automatic chapter break detection
- Embeds cover art if specified
- Resumes where it left off if interrupted
- NOTE: epub file must be DRM-free
Usage instructions
NOTE: If you want to specify where NLTK tokenizer will be stored (about 50mb), use an environment variable: export NLTK_DATA="your/path/to/nltk_data"
The included start.sh script automatically detects your hardware (Nvidia, AMD, MacOS, or CPU) and builds/runs the appropriate container.
# Make the script executable (only needed once)
chmod +x start.sh
# Run epub2tts-kokoro
./start.sh <arguments>Examples:
# Parse epub
./start.sh mybook.epub
# Read text to audiobook with specific speaker
./start.sh mybook.txt --cover mybook.png --speaker af_heartThe script manages volume mounts for the current directory and HuggingFace cache automatically. It supports both docker and podman.
source .venv/bin/activate
epub2tts-kokoro mybook.epub- edit mybook.txt, replacing
# Part 1etc with desired chapter names, and removing front matter like table of contents and anything else you do not want read. Note: First two lines can be Title: and Author: to use that in audiobook metadata.
epub2tts-kokoro mybook.txt --cover mybook.png- Optional: specify a speaker with
--speaker <speaker>. Check here for available voices, default speaker isaf_heartif--speakeris not specified. You can also generate speaker samples by running the scriptpython gen_samples.py
-h, --help- show this help message and exit--speaker SPEAKER- Speaker to use (example: af_heart)--cover image.[jpg|png]- Image to use for cover--paragraphpause <N>- Number of milliseconds to pause between paragraphs--speed <N>- Reading speed (ex 1.3)--notitles- Do not read chapter titles when creating audiobook
deactivate
How to report bugs/issues
Thank you in advance for reporting any bugs/issues you encounter! If you are having issues, first please search existing issues to see if anyone else has run into something similar previously.
If you've found something new, please open an issue and be sure to include:
- The full command you executed
- The platform (Linux, Windows, OSX, Docker)
- Your Python version if not using Docker
Release notes
- 20250224: Changed to read individual setences rather than entire paragraph, for reading speed consistency
- 20250221: Added
--notitlesoption - 20250216: Initial release
Required Python version is 3.11.
NOTE: If you want to specify where NLTK tokenizer will be stored (about 50mb), use an environment variable: export NLTK_DATA="your/path/to/nltk_data"
MAC INSTALLATION
This installation requires Python < 3.12 and Homebrew (I use homebrew to install espeak, pyenv and ffmpeg).
#install dependencies
brew install espeak pyenv ffmpeg
#install epub2tts-kokoro
git clone https://github.com/aedocw/epub2tts-kokoro
cd epub2tts-kokoro
pyenv install 3.11
pyenv local 3.11
#OPTIONAL - install this in a virtual environment
python -m venv .venv && source .venv/bin/activate
pip install .
LINUX INSTALLATION
These instructions are for Ubuntu 24.04.1 LTS and 22.04 (20.04 showed some depedency issues), but should work (with appropriate package installer mods) for just about any distro. Ensure you have ffmpeg installed before use.
#install dependencies
sudo apt install espeak-ng ffmpeg python3-venv
#clone the repo
git clone https://github.com/aedocw/epub2tts-kokoro
cd epub2tts-kokoro
#OPTIONAL - install this in a virtual environment
python3 -m venv .venv && source .venv/bin/activate
pip install .
WINDOWS INSTALLATION
Running epub2tts in WSL2 with Ubuntu 22 is the easiest approach, but these steps should work for running directly in windows.
(TBD)
UPDATING YOUR INSTALLATION
- cd to repo directory
git pull- Activate virtual environment you installed epub2tts in if you installed in a virtual environment using "source .venv/bin/activate"
pip install . --upgrade
👤 Christopher Aedo
👥 Contributors
Contributions, issues and feature requests are welcome!
Feel free to check the issues page or discussions page.
Give a ⭐️ if this project helped you!