Skip to content
Christopher Tapia
Menu
Kokoro Ebook Reader logo — a white letter K on a violet rounded square.
Kokoro Ebook Reader

Solo engineer · 2026 — April to October

Kokoro Ebook Reader — synchronized TTS, offline reading

A local-first PDF/EPUB reader that reads books aloud with word-level synchronized Kokoro-82M narration: a pre-rendered audio pipeline, four swappable TTS engines, and an offline PWA that keeps reading in the user's hands — not a cloud service's.

  • Svelte 5
  • FastAPI
  • Python
  • Kokoro 82M
  • ONNX Runtime
  • PyMuPDF
  • ffmpeg
  • Docker

The pitch for every subscription ebook service is that your books are convenient — for them. Kokoro Ebook Reader takes the opposite side: your PDFs and EPUBs sit on your own hardware, and the text-to-speech runs there too. It is a local, self-hosted reader that reads books aloud with word-level synchronized narration, built the way I wish every reading app worked — and it is a personal project, not client work: no customer, no stakeholder, just the product I use.

What the project answers: PDF and EPUB are the formats in, narration and a real reading surface are what come out. Repository: github.com/christapi2099/ebook-reader.

The reader

The reading surface handles the two formats that matter — PDF and EPUB — through different doors: PDF.js renders the original layout with a sentence overlay drawn over the actual page, while EPUB text reflows with bionic-reading weighting (fixation and bold-ratio are user settings, not a gimmick toggle). Around the page sit the boring-but-real parts of a reading product: bookmarks, folders, a library grid, full-text search, themes, reading progress, and an MP3 export for taking a chapter to the car.

The reader on a dark theme: a PDF page rendered by PDF.js with the currently read sentence highlighted in yellow on the page, a page navigator and reading-voice picker in the toolbar, and a media bar at the bottom with a progress slider, skip buttons, play control, and speed tiers from 0.75x to 3x.

The PDF reading surface in the dark theme. PDF.js renders the original page, the narration’s current sentence is highlighted in place, and the media bar underneath carries the speed tiers (0.75×–3×) and sentence-skip controls of the loaded render.

The thing that makes it a talking reader rather than a PDF with an audio file stapled to it is the sync manifest. Word-level timings — and PDF bounding boxes — flow from the alignment stage to the frontend, so the highlight tracks the voice, the sentence highlights on the rendered page, and locking the screen on an iPad keeps the chapter playing through Media Session controls.

The narration pipeline

Reading a chapter aloud should feel instant in the player, so nothing synthesizes live during playback. Each document goes through an immutable render pipeline: extract the text, synthesize it once, force-align the audio to the text, then encode the result as Ogg Opus at four speed tiers — 1.5×, 2.0×, 2.5×, and 3.0× — plus WebM copies for streaming. The player receives a gzip-verified sync manifest and fetches chunks; switching speed is a different artifact, not a pitch-shifted stutter.

The synthesis itself is Kokoro-82M, and how it runs is a runtime decision, not an architecture decision: four engines are behind one manager and hot-swappable through the API — the torch pipeline on a local GPU, Kokoro-82M through ONNX Runtime for leaner CPU/GPU machines, Piper as a lightweight fallback, and a remote Modal GPU for machines with none. Same voices, same manifest, whichever engine you can afford to run.

The voice picker screen: Kokoro's built-in American and British voices as cards in a grid, each with a colored avatar, its voice id, gender, and a play button for an audio preview; the active reading voice (Heart, af_heart) is outlined.

The voice picker, on the dark theme. The active reading voice is marked (af_heart here), and every voice has its own preview button. The voices are the ones the Kokoro-82M model ships.

Mid-playback in the PDF reader: the synced sentence highlight follows the narration while the progress slider and time counter advance. Recorded headless with the output muted — the highlight is driven by the audio clock, so what you see was heard.

Offline and installation

The library screen: a 'Resume reading' banner for the last opened book, a title search box, and a grid of book cards showing covers, page counts, and reading progress; the most recently uploaded PDF is queued for rendering.

The library grid on the dark theme: covers, progress bars and page counts for every document, the resume banner for the last open book, and a newly uploaded PDF sitting in the render queue until its narration generation is ready.

The frontend is an installable PWA: a service worker, OPFS storage for downloaded documents, an offline progress queue, and Add-to-Home-Screen on desktop and iPad (streamed as WebM/Opus over HTTPS — the tailnet deployment path is documented in the repo). For people who prefer a binary, the same app ships three ways: a Docker Compose stack built on NVIDIA CUDA images, a Flatpak manifest, and a Debian package.

Scale, honestly stated: this is the largest single-owner codebase linked from this site — 27 Svelte components on the frontend, roughly 13,500 lines of TS/Svelte against about 18,000 lines of Python, and 135+ test files across frontend unit tests, Playwright end-to-end specs, and backend pytest. It is not a demo with a landing page; it is an application with a test suite.

The 8-bit intro music on this site, incidentally, is the same spirit: local playback of things you control. Kokoro Ebook Reader is open source — the repository is the ledger for everything claimed above.

Technology attribution

Every technology shown in the chips above maps to an artifact in this project. Items that exist only in the engineering ledger are not rendered.

Technology attribution for Kokoro Ebook Reader — synchronized TTS, offline reading
TechnologyArtifact
Svelte 5Reader frontend (SvelteKit) — viewer, sync highlighting, library
FastAPILibrary, renders, and TTS-control API
PythonBackend: extraction, alignment, synthesis services
Kokoro 82MNarration voices (torch and ONNX runtimes)
ONNX Runtimekokoro-v1.0 ONNX engine for CPU/GPU inference
PyMuPDFPDF text and layout extraction
ffmpegOgg Opus speed tiers (1.5×–3×) and WebM copies
DockerCUDA GPU deployment (docker-compose)

Claims and sources

Quantitative claims in this case study carry a source and the date it was checked.

  • Kokoro Ebook Reader reads PDF and EPUB documents aloud with word-level synchronized TTS and sentence overlay on the PDF

    github.com/christapi2099/ebook-reader — backend/routers/documents.py (PDF/EPUB only) and docs/ARCHITECTURE.md (word timings + PDF boxes in the sync manifest) · checked

  • Narration is pre-rendered and re-encoded into Ogg Opus speed tiers (1.5×, 2.0×, 2.5×, 3.0×) with a sync manifest rather than synthesized live

    github.com/christapi2099/ebook-reader — docs/ARCHITECTURE.md render pipeline (immutable renders, Ogg Opus tiers, sync manifest, word timings) · checked

  • Four TTS engines are runtime-swappable: torch KPipeline, Kokoro-82M ONNX Runtime, Piper, and remote Modal GPU

    github.com/christapi2099/ebook-reader — backend/services/engine_manager.py (cpu/gpu/modal/piper engines) · checked

  • The frontend is a Svelte 5 / SvelteKit PWA with an installable manifest, service worker, and OPFS offline storage; iPad deployment waves are documented

    github.com/christapi2099/ebook-reader — frontend/static/manifest.webmanifest, frontend/src/service-worker.ts, frontend/src/lib/offline/ (10 modules), docs/IPAD-ENABLEMENT.md · checked

  • The project deploys three ways — Docker Compose on NVIDIA CUDA 12.6 images, a Flatpak manifest, and a Debian .deb builder

    github.com/christapi2099/ebook-reader — docker-compose.yml, backend/Dockerfile, flatpak/com.kokororeader.App.yml, scripts/build-deb.sh · checked

  • The codebase is the largest single-owner project here: 27 Svelte components in the frontend, 27 backend API routers/services areas, and 135+ test files (54 frontend unit, 10 Playwright e2e, 70 backend pytest)

    github.com/christapi2099/ebook-reader — frontend/src/lib/components/, backend/routers/ + backend/services/, tests trees (counts from the repo tree, 2026-11-15) · checked

← All work