Case study
Audiobook AI
Any document, read aloud.
Turns a PDF, EPUB, DOCX, web page, or pasted text into a continuous audiobook, synthesized with the open-source Kokoro text-to-speech model on PyTorch.
Turning arbitrary documents into listenable audio is a pipeline problem, not a single API call. This page documents the pipeline and the hardening that keeps it running under load.
Kokoro TTS · PyTorch · FastAPI · Worker Queue · PWA · Cloudflare Tunnel
A messy document becomes one continuous, listenable audiobook.
What actually happens
What goes in
A 300-page PDF with headers, footnote markers, “$4.2M in 2019”, and a paragraph of Chinese.
What comes out
The problem
Real documents are messy.
PDFs, EPUBs, and web pages carry headers, footnote markers, and broken layout that a model would read aloud verbatim.
Numbers and other scripts do not read themselves.
“$4.2M”, “2019”, and a line of Chinese each need to become the words a listener expects to hear.
Long books cannot be synthesized in one pass.
Text has to be chunked into segments and the audio stitched back into one continuous track, without seams the ear can catch.
What it reads
One ingest layer resolves each format down to the same clean chapter text, so the rest of the pipeline never has to know where the document came from.
The system
Ingest, normalize, chunk, synthesize with Kokoro, then assemble. Each stage hands a single clean shape to the next.
Reliability under load
Synthesis is slow and heavy, so it is kept off the request path. A FastAPI server accepts jobs and a separate worker process does the work, with the guardrails below drawn from the production environment flags.
The listening experience
The front end is a progressive web app served over HTTPS through a Cloudflare Tunnel, so a finished audiobook behaves like a native one.
Offline retention
A service worker caches finished audio per user, so a downloaded book keeps playing with no connection, including range requests for seeking.
Lock-screen playback
Audio plays from the phone lock screen with native transport controls, which is why HTTPS is required rather than optional.
Install and preview
A web app manifest lets the site install to the home screen, and a voice-samples page lets a listener hear a voice before committing a whole book to it.
The through-line
This is the text-to-speech side of the same voice craft as KOTA. KOTA takes messy speech and resolves it into a clean, verified result; Audiobook AI takes messy documents and resolves them into clean, continuous audio. Same shape, run in the other direction: messy input, a hardened pipeline, an output you can trust.
Audiobook AI is live. You can open it and run a document through the pipeline yourself.