Skip to content

Repository files navigation

audiobook-foundry

audiobook-foundry

Drop a PDF, EPUB, or URL into a folder – get a chaptered M4B audiobook in your library, narrated by free Microsoft Edge neural voices. Unattended, self-hosted, $0.

Why this exists

Most text-to-audiobook tools are either interactive apps you babysit, or cloud pipelines that bill an Azure subscription per book. audiobook-foundry is the third thing: a watch-folder pipeline for homelabs. Each watched directory is bound to a voice; anything dropped in gets converted end-to-end (PDF → EPUB → chaptered M4B with cover art) and lands in your audiobook library – Audiobookshelf auto-detects it, but the output is a standard M4B any player can use. A small web UI handles uploads and URL fetches from your phone; ntfy tells you when the book is ready.

Features

  • Watch-folder automation – one directory per voice; inotify-driven, processes backlog on start
  • PDF, EPUB, and URL inputs – PDFs converted via Calibre's ebook-convert; .url files fetch remote PDFs
  • Free neural voices – Microsoft Edge voices via edge-tts / epub2tts-edge; any voice from edge-tts --list-voices works, in any language
  • Proper audiobooks – chaptered M4B with embedded cover; source EPUB and a skipped-sentences report stored alongside
  • Metadata sanitizer – caps runaway description/comment tags in the output (see below)
  • Resilient narration – a build-time patch to epub2tts-edge skips unspeakable sentences and survives endpoint failures with short silence placeholders (logged per book in skipped_sentences.txt) instead of aborting a 40-minute conversion
  • Web UI (port 5051) – per-voice upload cards, live conversion status, completed-books table; mobile-friendly, dark-mode aware
  • ntfy notifications – success/failure pushes with size and title
  • Author - Title.ext convention – filenames become library metadata

Quickstart

git clone https://github.com/<you>/audiobook-foundry.git
cd audiobook-foundry
cp .env.example .env          # edit voices, paths, ntfy topic
docker compose -f docker-compose.example.yml up -d --build
# open http://<host>:5051 – or just drop "Author - Title.epub" into ./input/<voice>/

Configuration

Everything is environment-driven; defaults in parentheses.

Variable Purpose
AF_VOICES Comma-separated subdir:EdgeVoiceName pairs (ro-emil:ro-RO-EmilNeural,ro-alina:ro-RO-AlinaNeural,en-ryan:en-GB-RyanNeural,en-sonia:en-GB-SoniaNeural). Each subdir becomes a watched folder bound to that voice.
AF_INPUT_ROOT Root of the watched folders (/input)
AF_OUTPUT_DIR Library output root; books land at $AF_OUTPUT_DIR/Author/Title/ (/audiobooks)
AF_MAX_DESCRIPTION_CHARS Cap for text metadata tags in the final M4B; 0 disables (4000)
AF_CHAPTER_WARN Log a warning above this many chapters (200)
NTFY_URL Full ntfy topic URL, e.g. https://ntfy.example.com/audiobooks; empty disables
AF_PORT Web UI port (5051)

The metadata sanitizer (a war story)

Some ebook sources yield M4Bs whose description/comment tags contain megabytes of text. Library servers ingest that faithfully – and then at least one Android client (ShelfDroid) crashes on launch with SQLiteBlobTooBigException, because a single metadata row exceeds Android's hard 2 MB CursorWindow. audiobook-foundry now caps oversized text tags at the generation boundary with a lossless stream-copy remux, so every downstream client is protected. If you want gigantic embedded descriptions, set AF_MAX_DESCRIPTION_CHARS=0 and enjoy your crashes.

Build notes

The image clones epub2tts-edge at HEAD and applies patch_epub2tts.py, which replaces its run_edgespeak by function-boundary regex – if upstream refactors that function, the build fails loudly at the patch's asserts rather than producing a fragile image. Pinning a known-good upstream commit in the Dockerfile is a welcome first PR.

Alternatives (honest positioning)

  • HearThat – multi-voice, LLM scene-aware narration on Azure AI Speech/OpenAI. Gorgeous output, requires a paid Azure stack; interactive rather than unattended.
  • ebook2audiobook – local XTTS/GPU voice cloning, huge feature matrix. Heavier; different voice tech.
  • epub2tts-edge – the excellent converter this project wraps. Use it directly if you want a CLI, not a pipeline.

audiobook-foundry's corner: free voices, zero attention, library-native output.

Origins: lrrr

This pipeline was built for a Futurama-themed homelab, where it runs as lrrr – RULER OF THE PLANET OMICRON PERSEI 8, the franchise's loudest character and therefore the obvious name for a machine that turns silent text into a booming voice. The public name changed; the container at home never will.

⚠️ Provenance and honesty disclaimer

This project was vibe-coded – written collaboratively with Claude (Anthropic's AI assistant) and a human operator, iterating until it worked. It has not been formally reviewed, audited, or tested beyond running it and observing the results in a single homelab. There is no test suite. It converts ebooks to audiobooks on one person's server and does so happily, but treat every line with appropriate suspicion, and assume edge cases were discovered by collision rather than design. Use at your own risk; issues and pull requests are very welcome – that's rather the point of publishing it.

Microsoft non-affiliation: this project is not affiliated with or endorsed by Microsoft. It relies on the free Edge read-aloud endpoint through the unofficial edge-tts library – an endpoint that may be rate-limited, changed, or withdrawn at any time. That is this project's single biggest operational risk, disclosed here on purpose.

Content note: convert books you have the right to convert. The tool is format plumbing; the responsibility is yours.

License

MIT – use, fork, contribute, as it should be.

About

No description, website, or topics provided.

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages