ebook-to-audiobook
Local, resumable, multi-voice audiobooks. Proven on The Good Earth chapter 1: 50:20 of
audio, 11 designed voices, 307 local synthesis calls (0 failures, 0 paid TTS), 24 sampled
chunks at 1.14% ASR word error. Everything below is what that run taught.
extract_pages -> prepare_chapter text -> research cast -> (design_voice) -> prepare_chapter quotes/build
-> render_chapter prepare -> voices -> render -> verify_audio -> report -> (usage.py)
every step mirrors into <book>/book.json (voices, progress, artifacts)
Scripts live in scripts/ (stdlib-first Python 3.11+, python3 -B). Set
S=~/.agents/skills/ebook-to-audiobook/scripts. Tests: cd $S && python3 -B -m unittest discover -s tests.
Preflight (30 seconds, before any render)
voxxy health --json is not enough (it lists only the routed engines). Check VoxCPM itself:
docker exec vox curl -fsS --max-time 10 http://voxxy-engine-voxcpm:8000/healthz must say ready: true.
Stopped? docker start voxxy-engine-voxcpm (details: voice-design).
nvidia-smi has headroom (VoxCPM ~5 GB; VibeVoice ~7.5 GB; both can be resident).
ffmpeg, and for QA the transcription-worker-1 container (override with ABK_ASR_* env).
- Rights: record them in
book.json (source.rights). A 1931 US work enters the public domain
on 2027-01-01 (95 years). Personal listening from a supplied copy is the working assumption.
Book workspace
One directory per book (default location ~/audiobooks/<slug>/ or inside the project):
<book>/book.json single source of truth: voices, progress, artifacts, usage
<book>/source/ original file (hashed, not copied) + pages/page-NNN.txt
<book>/research/ characters.json (cast bible), chapter-NN.json (who speaks, evidence)
<book>/voices/<id>.wav frozen reference clips - the book's voice library
<book>/chapters/NN/ chapter.txt, speakers.json, chapter.json, audio/ (render output)
<book>/usage/ optional LLM snapshots + pricing assumptions
Never put the book under a git-tracked repo with the audio (WAVs are ~290 MB per hour); keep
book.json, research and manifests in git if you version them, ignore audio/ and voices/*.wav.
Workflows
| Task |
Do this |
Detail |
| New book, or "where was I?" |
book.py init, book.py show, book.py resume (prints the next commands) |
book-metadata |
| Research the characters in a chapter |
extract text, number the quotes, attribute speakers, write the cast |
character-research |
| Create a voice with Voxxy/VoxCPM2 |
design_voice.py design takes -> listen + ASR -> freeze; or let render_chapter.py voices design a chapter's new cast |
voice-design |
| Convert one chapter to audio |
prepare -> voices -> render -> verify -> report; resume with book.py resume |
chapter-conversion |
| Track tokens and cost (optional) |
usage.py capture --children, cost, record |
usage-accounting |
| Script |
Role |
book.py |
manifest CLI: init, voice add/list, chapter set, progress set/show, artifact add/verify, import-render, resume, show |
extract_pages.py |
PDF (text layer, else OCR) or EPUB -> page-NNN.txt |
prepare_chapter.py |
text (pages -> chapter.txt), quotes (numbered spans), build (-> chapter.json, verified lossless) |
design_voice.py |
design (N takes from a description), list, freeze (take -> voices/<id>.wav + book.json); no chapter needed |
render_chapter.py |
prepare, voices, preview, render, redo, status, report; direct VoxCPM2, resumable, ledgered |
verify_audio.py |
CPU Whisper spot-check, sample-scoped WER |
usage.py |
optional: OpenCode token capture (with child sessions), API-equivalent cost, energy scenario, record into book.json |
Fast path for one chapter (replace every <...>; the pilot's values are in the reference files):
S=~/.agents/skills/ebook-to-audiobook/scripts; B=~/audiobooks/<slug>; SRC=<path/to/book.pdf|epub>; N=1; NN=01
python3 -B $S/book.py --dir $B init --title "<Title>" --author "<Author>" --source $SRC # once per book
python3 -B $S/extract_pages.py $SRC --out $B/source/pages --first <p> --last <q>
python3 -B $S/prepare_chapter.py text --pages-dir $B/source/pages --first <p> --last <q> --out $B/chapters/$NN/chapter.txt \
--start-marker "<this chapter's heading>" --end-marker "<next chapter's heading>" --strip-folio --auto-join
python3 -B $S/prepare_chapter.py quotes --text $B/chapters/$NN/chapter.txt # attribute every span, write speakers.json
python3 -B $S/prepare_chapter.py build --text $B/chapters/$NN/chapter.txt --speakers $B/chapters/$NN/speakers.json --book $B --chapter $N
M=$B/chapters/$NN/chapter.json; O=$B/chapters/$NN/audio
for c in prepare voices render; do python3 -B $S/render_chapter.py $c --manifest $M --output $O --book $B || break; done
python3 -B $S/verify_audio.py --manifest $M --root $O --phase all --max-chunks 24
python3 -B $S/render_chapter.py report --manifest $M --output $O --book $B # registers QA, marker -> qa
--book makes every render step mirror voices, artifacts and the progress marker into book.json,
including after a failure, so a hung session or a crashed render is resumable from the file alone:
book.py --dir $B resume prints the exact commands for the furthest chapter and stage.
Gotchas that cost real time
- Never route a book through the public vox API or
voxxy speak. They cannot pin an engine. On the
pilot day core's chain was VibeVoice -> ElevenLabs with VoxCPM2 absent; a request would have come back
in a different voice and looked fine. render_chapter.py calls the VoxCPM sidecar directly and treats
engine != "voxcpm" as a hard failure. voxxy engine use changes shared service state; do not.
- Do not run
voxxy daemon start|restart or voxxy engine use during a render. daemon start stops
every local engine except the routed one (VoxCPM when VibeVoice is routed), and restart/engine use
recreate vox, which carries every synth call (docker exec vox curl ...): in-flight chunks fail.
- Design once, freeze, reuse.
(description)reference_text is for the reference clip only. Chapter text
is conditioned on the clip's audio and never carries a description (a description mid-text is read aloud).
Pin a book's voices across chapters (prepare_chapter.py build --book), or each chapter will cast new actors.
- Reference text is neutral and original (15-20 words, about 8 s), never chapter content; descriptions
stay under 20 words with no parentheses. Longer descriptions degrade the voice.
- Health lies about sample rate (reports 16 kHz; real output is 48 kHz). Trust WAV headers.
- Do not retry a timed-out request blindly. A client timeout does not stop the GPU. Confirm the engine is
idle, then
--retry-failed. Stale or hand-edited caches are refused; use a fresh output dir after a manifest change.
- Quote attribution is the real work. Count and pin every quoted span; unbalanced curly quotes, quoted
thoughts, recalled speech and collective voices ("the vendors") all need a decision. Pilot: 117 spans, 11 speakers.
- OCR a scanned PDF at
--psm 6, 300 dpi, review every page, and record each correction. Repair line-wrap
hyphens, page-spanning paragraphs, and OCR-turned periods (floor, Every). Keep uncertain wording and list it.
- Master the whole chapter once (two-pass loudnorm, -20 LUFS / -3 dBTP). Per-chunk normalization makes
voices pump. Expect true peak to land within about 0.1 dB of the target and say so rather than pretending.
- ASR QA is a diagnostic, not a verdict. CPU faster-whisper int8 keeps the GPU free; it misses
mispronunciation, flags names (Wang/Wong) and dashes. Listen to the worst few samples.
- TTS tokens are not LLM tokens. 9,906 VoxCPM text tokens vs 17.3M LLM tokens for the whole project. Keep two ledgers.
- OpenCode v2 removed
opencode export; read its sqlite DB read-only (usage.py does). A hung session
still has a readable DB and a complete requests ledger: check render_chapter.py status before redoing anything.
- No credentials in any manifest or snapshot; use
op:// references if a pricing or API note needs one.
1---2name: ebook-to-audiobook3description: Turn an ebook, scanned PDF or EPUB into a multi-voice audiobook chapter by chapter with the local Voxxy/VoxCPM2 engine on the RTX 3090 - book metadata and resume markers, character research, per-character voice design, single-chapter conversion with ASR QA, and optional token/cost accounting. Use when asked to narrate, convert, resume or continue an audiobook, design or reuse character voices for a book, or record what a book build used. Not for one-off speech or cloning a person's voice (vox-tts), upgrading the Voxxy engines (vox-tts), speech-to-text of existing audio, or publishing and distributing the result.4metadata:5 source: https://skillmd.com/skills/delorenj/ebook-to-audiobook6---78# ebook-to-audiobook910Local, resumable, multi-voice audiobooks. Proven on *The Good Earth* chapter 1: 50:20 of11audio, 11 designed voices, 307 local synthesis calls (0 failures, 0 paid TTS), 24 sampled12chunks at 1.14% ASR word error. Everything below is what that run taught.1314```15extract_pages -> prepare_chapter text -> research cast -> (design_voice) -> prepare_chapter quotes/build16 -> render_chapter prepare -> voices -> render -> verify_audio -> report -> (usage.py)17 every step mirrors into <book>/book.json (voices, progress, artifacts)18```1920Scripts live in `scripts/` (stdlib-first Python 3.11+, `python3 -B`). Set21`S=~/.agents/skills/ebook-to-audiobook/scripts`. Tests: `cd $S && python3 -B -m unittest discover -s tests`.2223## Preflight (30 seconds, before any render)24251. `voxxy health --json` is not enough (it lists only the *routed* engines). Check VoxCPM itself:26 `docker exec vox curl -fsS --max-time 10 http://voxxy-engine-voxcpm:8000/healthz` must say `ready: true`.27 Stopped? `docker start voxxy-engine-voxcpm` (details: [voice-design](references/voice-design.md#failure-modes-seen-or-expected)).282. `nvidia-smi` has headroom (VoxCPM ~5 GB; VibeVoice ~7.5 GB; both can be resident).293. `ffmpeg`, and for QA the `transcription-worker-1` container (override with `ABK_ASR_*` env).304. Rights: record them in `book.json` (`source.rights`). A 1931 US work enters the public domain31 on 2027-01-01 (95 years). Personal listening from a supplied copy is the working assumption.3233## Book workspace3435One directory per book (default location `~/audiobooks/<slug>/` or inside the project):3637```38<book>/book.json single source of truth: voices, progress, artifacts, usage39<book>/source/ original file (hashed, not copied) + pages/page-NNN.txt40<book>/research/ characters.json (cast bible), chapter-NN.json (who speaks, evidence)41<book>/voices/<id>.wav frozen reference clips - the book's voice library42<book>/chapters/NN/ chapter.txt, speakers.json, chapter.json, audio/ (render output)43<book>/usage/ optional LLM snapshots + pricing assumptions44```4546Never put the book under a git-tracked repo with the audio (WAVs are ~290 MB per hour); keep47`book.json`, research and manifests in git if you version them, ignore `audio/` and `voices/*.wav`.4849## Workflows5051| Task | Do this | Detail |52| --- | --- | --- |53| New book, or "where was I?" | `book.py init`, `book.py show`, `book.py resume` (prints the next commands) | [book-metadata](references/book-metadata.md) |54| Research the characters in a chapter | extract text, number the quotes, attribute speakers, write the cast | [character-research](references/character-research.md) |55| Create a voice with Voxxy/VoxCPM2 | `design_voice.py design` takes -> listen + ASR -> `freeze`; or let `render_chapter.py voices` design a chapter's new cast | [voice-design](references/voice-design.md) |56| Convert one chapter to audio | prepare -> voices -> render -> verify -> report; resume with `book.py resume` | [chapter-conversion](references/chapter-conversion.md) |57| Track tokens and cost (optional) | `usage.py capture --children`, `cost`, `record` | [usage-accounting](references/usage-accounting.md) |5859| Script | Role |60| --- | --- |61| `book.py` | manifest CLI: `init`, `voice add/list`, `chapter set`, `progress set/show`, `artifact add/verify`, `import-render`, `resume`, `show` |62| `extract_pages.py` | PDF (text layer, else OCR) or EPUB -> `page-NNN.txt` |63| `prepare_chapter.py` | `text` (pages -> chapter.txt), `quotes` (numbered spans), `build` (-> `chapter.json`, verified lossless) |64| `design_voice.py` | `design` (N takes from a description), `list`, `freeze` (take -> `voices/<id>.wav` + `book.json`); no chapter needed |65| `render_chapter.py` | `prepare`, `voices`, `preview`, `render`, `redo`, `status`, `report`; direct VoxCPM2, resumable, ledgered |66| `verify_audio.py` | CPU Whisper spot-check, sample-scoped WER |67| `usage.py` | optional: OpenCode token capture (with child sessions), API-equivalent cost, energy scenario, `record` into `book.json` |6869Fast path for one chapter (replace every `<...>`; the pilot's values are in the reference files):7071```bash72S=~/.agents/skills/ebook-to-audiobook/scripts; B=~/audiobooks/<slug>; SRC=<path/to/book.pdf|epub>; N=1; NN=0173python3 -B $S/book.py --dir $B init --title "<Title>" --author "<Author>" --source $SRC # once per book74python3 -B $S/extract_pages.py $SRC --out $B/source/pages --first <p> --last <q>75python3 -B $S/prepare_chapter.py text --pages-dir $B/source/pages --first <p> --last <q> --out $B/chapters/$NN/chapter.txt \76 --start-marker "<this chapter's heading>" --end-marker "<next chapter's heading>" --strip-folio --auto-join77python3 -B $S/prepare_chapter.py quotes --text $B/chapters/$NN/chapter.txt # attribute every span, write speakers.json78python3 -B $S/prepare_chapter.py build --text $B/chapters/$NN/chapter.txt --speakers $B/chapters/$NN/speakers.json --book $B --chapter $N79M=$B/chapters/$NN/chapter.json; O=$B/chapters/$NN/audio80for c in prepare voices render; do python3 -B $S/render_chapter.py $c --manifest $M --output $O --book $B || break; done81python3 -B $S/verify_audio.py --manifest $M --root $O --phase all --max-chunks 2482python3 -B $S/render_chapter.py report --manifest $M --output $O --book $B # registers QA, marker -> qa83```8485`--book` makes every render step mirror voices, artifacts and the progress marker into `book.json`,86including after a failure, so a hung session or a crashed render is resumable from the file alone:87`book.py --dir $B resume` prints the exact commands for the furthest chapter and stage.8889## Gotchas that cost real time9091- **Never route a book through the public vox API or `voxxy speak`.** They cannot pin an engine. On the92 pilot day core's chain was VibeVoice -> ElevenLabs with VoxCPM2 absent; a request would have come back93 in a different voice and looked fine. `render_chapter.py` calls the VoxCPM sidecar directly and treats94 `engine != "voxcpm"` as a hard failure. `voxxy engine use` changes shared service state; do not.95- **Do not run `voxxy daemon start|restart` or `voxxy engine use` during a render.** `daemon start` stops96 every local engine except the routed one (VoxCPM when VibeVoice is routed), and `restart`/`engine use`97 recreate `vox`, which carries every synth call (`docker exec vox curl ...`): in-flight chunks fail.98- **Design once, freeze, reuse.** `(description)reference_text` is for the reference clip only. Chapter text99 is conditioned on the clip's audio and never carries a description (a description mid-text is read aloud).100 Pin a book's voices across chapters (`prepare_chapter.py build --book`), or each chapter will cast new actors.101- **Reference text is neutral and original** (15-20 words, about 8 s), never chapter content; descriptions102 stay under 20 words with no parentheses. Longer descriptions degrade the voice.103- **Health lies about sample rate** (reports 16 kHz; real output is 48 kHz). Trust WAV headers.104- **Do not retry a timed-out request blindly.** A client timeout does not stop the GPU. Confirm the engine is105 idle, then `--retry-failed`. Stale or hand-edited caches are refused; use a fresh output dir after a manifest change.106- **Quote attribution is the real work.** Count and pin every quoted span; unbalanced curly quotes, quoted107 thoughts, recalled speech and collective voices ("the vendors") all need a decision. Pilot: 117 spans, 11 speakers.108- **OCR a scanned PDF at `--psm 6`, 300 dpi**, review every page, and record each correction. Repair line-wrap109 hyphens, page-spanning paragraphs, and OCR-turned periods (`floor, Every`). Keep uncertain wording and list it.110- **Master the whole chapter once** (two-pass loudnorm, -20 LUFS / -3 dBTP). Per-chunk normalization makes111 voices pump. Expect true peak to land within about 0.1 dB of the target and say so rather than pretending.112- **ASR QA is a diagnostic, not a verdict.** CPU faster-whisper int8 keeps the GPU free; it misses113 mispronunciation, flags names (Wang/Wong) and dashes. Listen to the worst few samples.114- **TTS tokens are not LLM tokens.** 9,906 VoxCPM text tokens vs 17.3M LLM tokens for the whole project. Keep two ledgers.115- **OpenCode v2 removed `opencode export`**; read its sqlite DB read-only (`usage.py` does). A hung session116 still has a readable DB and a complete requests ledger: check `render_chapter.py status` before redoing anything.117- No credentials in any manifest or snapshot; use `op://` references if a pricing or API note needs one.