A command-line tool and library that converts EPUB ebooks to OGG audiobooks with chapter markers, using local text-to-speech processing with Kokoro.
- Converts EPUB 3.0 files to OGG audiobooks
- Local text-to-speech processing using Kokoro
- Support for 9 languages with multiple voices:
- ๐บ๐ธ American English (11F, 9M voices)
- ๐ฌ๐ง British English (4F, 4M voices)
- ๐ฏ๐ต Japanese (4F, 1M voices)
- ๐จ๐ณ Mandarin Chinese (4F, 4M voices)
- ๐ช๐ธ Spanish (1F, 2M voices)
- ๐ซ๐ท French (1F voice)
- ๐ฎ๐ณ Hindi (2F, 2M voices)
- ๐ฎ๐น Italian (1F, 1M voices)
- ๐ง๐ท Brazilian Portuguese (1F, 2M voices)
- Chapter markers in output files
- Configurable voice selection and speech rate
- Progress reporting with optional quiet mode
- Metadata preservation from EPUB to audio file
- Python 3.10 or higher
- Dependencies listed in
pyproject.toml
- Pip install
pip install epub2audio- Clone this repository:
git clone https://github.com/clayrosenthal/epub2audio.git
cd epub2audio- Install dev setup using mise (recommended):
mise installOr manually with a virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -e .Convert an EPUB file to an audiobook with default settings:
epub2audio input.epubThe audiobook will be saved as Book_Title.ogg, but can be set with --output.
The tool supports multiple voices across different languages. Here are some notable voices:
af_bella(Female, Grade A-) - High quality with extended trainingaf_heart(Female, Grade A) - Best overall qualityaf_nicole(Female, Grade B-) - Good quality with extended trainingam_fenrir(Male, Grade C+) - Best male voice option
bf_emma(Female, Grade B-) - Best British female voicebm_fable(Male, Grade C) - Best British male voice
ff_siwis(French Female, Grade B-)jf_alpha(Japanese Female, Grade C+)if_sara(Italian Female, Grade C)hf_alpha(Hindi Female, Grade C)
To use a specific voice:
epub2audio input.epub --voice af_bellaepub2audio input.epub \
--output output.ogg \
--voice af_bella \
--speech-rate 1.0 \
--quietinput.epub: Path to input EPUB file--output,-o: Path of output audiobook file, defaults to title of the ebook.--voice,-v: Name of the voice to use (default: af_heart)--speech-rate,-r: Speech rate multiplier (default: 1.0)--quiet,-q: Suppress progress reporting--verbose,-v: Output more verbose logs--cache,-c: Cache generated audio files for reuse--max-chapters,-m: Max number of chapters to generate, or -1 for unlimited--format,-f: Output container format
Voices are graded based on quality and training data:
- A: Exceptional quality, extensive training
- B: Good quality, suitable for most uses
- C: Average quality, may have minor issues
- D: Basic quality, may have noticeable issues
- F: Limited quality, recommended only if necessary
Modifiers (+/-) indicate slight variations within each grade.
src/
โโโ __init__.py
โโโ epub_processor.py # EPUB parsing and text extraction
โโโ audio_converter.py # TTS conversion using Kokoro
โโโ audio_handler.py # OGG creation, chapter markers, metadata
โโโ epub2audio.py # Main class, command line interface
โโโ voices.py # Voice definitions and management
โโโ helpers.py # Utility functions
โโโ config.py # Configuration settings
Using mise:
# Run all tests
mise run test
# Run integration tests
mise run test-integration
# Run with coverage
mise run test-coverageOr manually:
# Run all tests
pytest
# Run integration tests
pytest --run-integration
# Run with coverage
pytest --cov=src tests/The project uses:
- Ruff for formatting and linting
- MyPy for type checking
- Pytest for testing
To format and lint code:
mise run format # Format code
mise run lint # Check code
mise run fix # Auto-fix issues- Invalid/corrupted EPUB file
- Invalid voice model selection
- File system errors (read/write permissions)
- Insufficient disk space
- Non-text elements in EPUB
- Unsupported metadata fields
- Minor formatting issues
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
mise run test) - Format code (
mise run format) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Add support for epub by link
- Add support for taking in multiple epubs on the command kine
- Add a webserver so you could host this
- Add support for more audio output formats
- Add support for images and vector graphics
- Either their alt text, or generate it with AI
- Better integration tests
- Add support for ONNX runtime
- Add support for other AI models
- Follow Google Python style guide
- Add tests for new features
- Update documentation as needed
- Keep commits focused and atomic
AGPL-3.0-or-later - See LICENSE file for details
- Kokoro for text-to-speech processing
- Huggingface for model weights
- ebooklib for EPUB handling
- mutagen for audio metadata
- Voice training data contributors (see individual voice attributions)