book-to-audiobook
CLAUDE.md9 starsChanged 4 months agoMITView on GitHub
ffmpeg must also be on PATH (brew install ffmpeg / apt install ffmpeg) — pydub shells out to it for audio conversion/concatenation. There is no lint/format tool configured (requirements-dev.txt only has pytest) — don't invent ruff/flake8/black commands that aren't set up. CLI (the same entry point the Claude Code skill drives via Bash — see Architecture below): .claude/skills/book-to-audiobook/SKILL.md defines an 8-gate conversation (setup → book/preferences → inspect → confirm start/end cut → confirm metadata → translate → review pronunciation →…
- Reads credentials
- Installs packages
In this repositoryOne other file it gives its agents.
- book-to-audiobookSkill
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
When changing CLI JSON output shape, check SKILL.md first — it parses specific keys (boundary_candidates[].kind/preview, cleaning, …
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commands
Setup:
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txtffmpeg must also be on PATH (brew install ffmpeg / apt install ffmpeg) — pydub shells out to it for audio conversion/concatenation.
Tests:
pytest # full suite
pytest tests/test_pipeline.py # one file
pytest tests/test_pipeline.py::test_name -v # one testThere is no lint/format tool configured (requirements-dev.txt only has pytest) — don't invent ruff/flake8/black commands that aren't set up.
CLI (the same entry point the Claude Code skill drives via Bash — see Architecture below):
python -m src.cli doctor
python -m src.cli inspect <path> --json
python -m src.cli voices --lang <code> --json
python -m src.cli pronunciation <path> --start-char N --end-char M [--source-lang X --translate-to Y] --json
python -m src.cli convert <path> --start-char N --end-char M --voice V --source-lang X --rate R [--translate-to Y] --output out.mp3Architecture
A conversational skill wraps a deterministic CLI
.claude/skills/book-to-audiobook/SKILL.md defines an 8-gate conversation (setup → book/preferences → inspect → confirm start/end cut → confirm metadata → translate → review pronunciation → convert → review result). The skill does no text processing itself — it only shells out to python -m src.cli <subcommand> and surfaces real output (boundary previews, flagged tokens, translated prose) to the user at each gate before proceeding. All actual logic lives in src/.
When changing CLI JSON output shape, check SKILL.md first — it parses specific keys (boundary_candidates[].kind/preview, cleaning, flagged_tokens) and the gate flow depends on them.
No hidden defaults, anywhere
Every operational parameter — voice, source/target language, start/end char offsets, playback rate — is an explicit CLI argument on every call. Nothing is read from .env (.env.example is currently just a placeholder for a future paid TTS/OCR API key) or silently inferred. The only thing persisted across calls is the extraction/translation cache described below. Keep this property when adding parameters: no auto-detection, no stored "last used" defaults.
Extraction → clean → boundary → translate, all keyed through src/text_cache.py
read_or_extract_raw/read_or_extractdispatch tosrc/loaders/(epub/pdf/txt, chosen by extension inloaders/__init__.py) and cache the raw extracted text at.cache/<slug>.txt, keyed only by the book's filename slug — re-runninginspectorconvertnever re-parses the source file.src/cleaning.pystrips decorative separator lines (repeated-symbol scene breaks) and rewrites roman-numeral chapter headings to digits, returning stats (decorative_lines_removed,roman_chapters_converted) thatcli.py inspectreports back. This runs automatically, before boundary offsets are computed, so char offsets the user confirms are against the cleaned text.src/boundary.pyfinds candidate start/end points (Gutenberg markers, chapter headings, table of contents, front/back matter) and applies the human-confirmed--start-char/--end-char.read_or_translatecaches the translated, already-trimmed text at.cache/<slug>.<start_char>-<end_char>.<target>.txt, keyed by the confirmed offsets and target language. This is the mechanism that lets the pronunciation gate and the convert step share one translation instead of doing it twice — both call this same function with the same key.src/pronunciation.pyflags acronyms/numbers/capitalized-mid-sentence words in whatever text will actually be spoken (the translated cache if a translation was requested, the cleaned/trimmed source otherwise) — never the raw untranslated source when translation is in play.
Synthesis (src/pipeline.py)
convert_book_to_audio builds a short intro line from metadata (src/metadata.py + src/intro.py), synthesizes intro and body separately, then concatenates them (src/tools.py:combine_audio_files). Body text is split into N word-safe chunks (tools.py:split_text_into_parts) and synthesized part-by-part through edge-tts (src/text_to_speech.py). If synthesis fails partway through, it retries with progressively more/smaller chunks (the MAX_CHUNKS loop) instead of failing outright. After combining, output duration is sanity-checked against a words-per-minute estimate and a [WARN] (not an exception) is printed if the audio looks truncated — see the # ponytail: comments in pipeline.py, which mark the known ceilings of these heuristics (chunk count, WPM estimate) and what to do if they start false-positiving.
Metadata extraction is format-dependent
src/metadata.py reads real EPUB DC metadata (title/author/subtitle) for .epub. For .pdf/.txt there is no such metadata, so it falls back to "first non-blank line of text as title" with no author/subtitle.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

