Convert ebooks (EPUB, PDF, TXT) to audiobooks (M4B/MP3) with chapter markers
Project description
Book to Audiobook
Convert ebooks (EPUB, MOBI, AZW3, PDF, TXT) to audiobooks (M4B / MP3) with chapter markers.
Prerequisites
Install
pip install book-to-audiobook
From source:
git clone https://github.com/hugcosmos/book-to-audiobook.git
cd book-to-audiobook
pip install -e .
Quick Start
# Web UI
book2audio serve # http://localhost:8000
# CLI
book2audio chapters book.epub # preview chapters
book2audio convert book.epub -c 1-10 # convert chapters 1-10
book2audio doc # full command reference
CLI Reference
Run book2audio doc for detailed help, or book2audio <command> --help.
| Command | Description |
|---|---|
convert |
Convert ebook to audiobook |
chapters |
List, view (-t N), and edit (-e N) chapters |
voice |
Manage voices (list/add/delete) |
config |
Manage configuration |
library |
Manage audiobook library |
serve |
Start web server |
doc |
Show full documentation |
Convert
book2audio convert book.epub
book2audio convert book.epub -c 1-10 -p edge-tts -v zh-CN-XiaoyiNeural -s 1.2
book2audio convert --book-id a74e947e332e -c 11-20
book2audio convert book.pdf -p qwen3_mlx -l en-US
Chapters
book2audio chapters book.epub # list chapters
book2audio chapters book.epub -t 3 # view chapter 3 text
book2audio chapters book.epub -t 3 --head 20 # first 20 lines only
book2audio chapters book.epub -e 3 # edit chapter 3 in $EDITOR
book2audio chapters --book-id abc123 -e 3-5 # edit chapters 3-5
Edited text is saved separately (original never modified). Conversion uses edited text automatically. Edited chapters show [edited] tag.
Web UI
Open http://localhost:8000. Drag & drop ebooks, select chapters, configure TTS, convert. Chapter text can be edited inline via the edit button on each chapter.
CLI and Web share the same library — books, edits, and conversion records persist across both.
TTS Providers
Cloud
| Provider | Setup | Cost |
|---|---|---|
| Edge TTS | No config needed | Free |
| ElevenLabs | B2A_ELEVENLABS__API_KEY |
Paid |
| Baidu TTS | B2A_BAIDU_TTS__API_KEY + B2A_BAIDU_TTS__SECRET_KEY |
Paid |
| iFlytek TTS | B2A_IFLYTEK_TTS__APP_ID + B2A_IFLYTEK_TTS__API_KEY + B2A_IFLYTEK_TTS__API_SECRET |
Paid |
Local — Qwen3 TTS via MLX (Apple Silicon)
On-device, no API key. Requires Apple Silicon Mac (M1+).
pip install hf-transfer
export HF_HUB_ENABLE_HF_TRANSFER=1
# China users: export HF_ENDPOINT=https://hf-mirror.com
| Model | Size | Quality | Memory |
|---|---|---|---|
0.6B-CustomVoice-8bit |
Default | Good | ~0.6GB |
1.7B-CustomVoice-4bit |
Larger | Great | ~0.85GB |
1.7B-CustomVoice-8bit |
Larger | Great | ~1.7GB |
Set via Settings page or book2audio config set qwen3_mlx.model_name <model>.
Supported Languages
Chinese (zh-CN/TW/HK), English (US/UK), Japanese, Korean, French, German, Spanish, Russian, Portuguese, Italian.
Configuration
Environment variables with B2A_ prefix, or book2audio config set:
book2audio config show
book2audio config set tts.provider edge-tts
book2audio config set qwen3_mlx.speed 1.2
| Variable | Default | Description |
|---|---|---|
B2A_HOST |
0.0.0.0 |
Server bind address |
B2A_PORT |
8000 |
Server port |
B2A_UPLOAD_DIR |
uploads |
Ebook storage |
B2A_OUTPUT_DIR |
output |
Audio output |
Project Structure
app/ # FastAPI web app (routes, templates, static)
cli/ # Click CLI commands
core/ # converter, models, parsers, TTS providers, audio builder
config/ # Settings (pydantic-settings) + user_settings.json
uploads/ # Uploaded ebooks + chapter edits + meta.json
output/ # Generated audiobook files
Disclaimer
Edge TTS: This project includes edge-tts as one TTS provider, which connects to Microsoft Edge's online text-to-speech service. This is not an official Microsoft API and may violate Microsoft's Terms of Service.
Users can choose alternative providers (ElevenLabs, Baidu, iFlytek, or local Qwen3 MLX) to avoid Edge TTS. Use at your own risk — the authors are not responsible for any violations of third-party terms of service.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file book_to_audiobook-0.1.17.tar.gz.
File metadata
- Download URL: book_to_audiobook-0.1.17.tar.gz
- Upload date:
- Size: 70.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e5ad82c5b322588c91985c22d2c5ddbc2aa60a3f80ce17571e4d1050a2a54a0
|
|
| MD5 |
fbd4224f0bb9e6b268d507849f5f7044
|
|
| BLAKE2b-256 |
56e2cc19930ce61c20052fbac8eccf9349c576b7f36230570605307373079c42
|
File details
Details for the file book_to_audiobook-0.1.17-py3-none-any.whl.
File metadata
- Download URL: book_to_audiobook-0.1.17-py3-none-any.whl
- Upload date:
- Size: 85.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba207483bd7a21bf43fadbde3397a80454a6f1f182d55c92c7f40c5207515e48
|
|
| MD5 |
04ddc657949a09c1e04d42dbf2d20df0
|
|
| BLAKE2b-256 |
e19c91b57d6e1fe656d4c37fc0daca1d646975ec2e12fbce028b42c4ce8d7ff9
|