Note: This is a fork of Simple PDF to Audiobook. Original project by Estikno.
This project converts PDF books into AI-narrated audiobooks using Coqui-TTS (fork), PyMuPDF and jenkspy. Everything is done locally so there is no need for api keys, credits, etc.
- Multiple TTS engines - Support for three different text-to-speech engines (Coqui-TTS, Chatterbox-TTS, Kokoro-TTS)
- Dependency management - Added
pyproject.tomlwith uv support - Local AI development setup - Configured with LM Studio and Qwen3 Coder Next for local code assistance via opencode.json
- Sequential audio validation -
join_audios.pynow checks that all audio blocks are present and warns if any are missing from the sequence
This project includes a pyproject.toml for dependency management with uv:
To install required dependencies:
uv syncTo run the scripts below if you're using uv:
uv run python extract_text.py
uv run python classify.py
uv run python tts_chatterbox.py # or whatever tts engine you want to use
uv run python join_audios.py- Extract text from the PDF
python extract_text.py
- The script opens
book.pdf(the PDF must have this name). - It generates a file
vision_output.jsoncontaining the text blocks and their font sizes.
-
Classify text blocks
python classify.py
- Uses Jenks natural breaks to classify text as:
header(titles),body(main content),caption(subtitles),other(things to skip, e.g. page numbers).
- Saves the result as
classified_text.json.
- Uses Jenks natural breaks to classify text as:
-
Generate audio with Coqui-TTS
python tts.py
- Converts each block from
classified_text.jsoninto audio. - Produces one WAV file per block inside the
temp/folder.
👉 If you stop synthesis halfway through, it's fine:
all previously generated blocks remain in
temp/, and you can continue from there. - Converts each block from
-
Join the audio files
python join_audios.py
- Sorts audio blocks by number and validates they're sequential.
- Alerts if any blocks are missing from the sequence.
- Concatenates all
.wavfiles fromtemp/into a single finalaudiobook.mp3using FFmpeg.
You'll need these libraries and tools installed. If you're not using uv the pip commands are below for the python dependencies.
- FFmpeg (make sure it's in your PATH)
- Coqui-TTS (fork)
- PyMuPDF (
pip install PyMuPDF) - jenkspy (
pip install jenkspy) - Pydub (
pip install pydub)
- Chatterbox-TTS:
chatterbox-tts,peft,perth - Kokoro-TTS:
kokoro-tts(downloads model files automatically:kokoro-v1.0.onnx,voices-v1.0.bin)
This project uses a local LLM via LM Studio with opencode.json configuration:
- Model: Qwen3 Coder Next (local)
- Endpoint:
http://127.0.0.1:1234/v1(LM Studio default)
Start LM Studio, load your model, and enable the OpenAI-compatible server to use opencode features.
- The input PDF must be named
book.pdfand placed in the project folder. - For now the pipeline is very basic and experimental. If you don't mind tweaking some code, you can adjust things like:
- The page ranges to process.
- The thresholds for text classification.
- The voice or language in Coqui-TTS.
- If the book is long, the audio is split into small blocks (
temp/block_X.wav) so you don't lose progress. You can edit the TTS scripts to skip blocks you have already processed (seeSTART_BLOCKintts_chatterbox.py). - The join_audios.py script now validates that all audio blocks are present sequentially and warns if any are missing.
This project includes three different TTS engines:
tts.py- Uses Coqui-TTS (default, multilingual)tts_chatterbox.py- Uses Chatterbox-TTS for high-quality voice synthesis with audio conditioning. Find an AI narrator you prefer and provide a 30-second sample audio file (e.g.,audio_sample.mp3) to mimic that specific voice style.tts_kokoro.py- Uses Kokoro-TTS and supports different built in voice style options (lightweight, fast)
All scripts read from classified_text.json and output to temp/block_X.wav.
The following files are added to .gitignore and should not be committed:
- Audio files (
audiobook.mp3,audio_sample.mp3, etc.) - TTS model files (
kokoro-v1.0.onnx,voices-v1.0.bin) - TTS scripts (
tts_chatterbox.py,tts_kokoro.py) - Backup/classified text files (
classified_text_backup.json)