Skip to content

Narrate the book with Kokoro - #92

Closed
bc1cindy wants to merge 3 commits into
fungi-protocol:mainfrom
bc1cindy:narration
Closed

bc1cindy wants to merge 3 commits into
fungi-protocol:mainfrom
bc1cindy:narration

Conversation

@bc1cindy

@bc1cindy bc1cindy commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Narrate each chapter with Kokoro at build time, so the book can be listened to. Closes #76.

1116.1.-github.mp4

Narration reads a chapter's text aloud. Extract it without frontmatter,
code, diagrams, tables, markup or math, one heading, list item or
paragraph per line, and name its audio by the hash of the text, so audio
rendered from other text never stands in for it.
Render each chapter to one MP3 per voice inside the build, with the
Kokoro from nixpkgs and its weights and voices fetched by hash. Each
section, cut before each of the chapter's headings, is read by its own
derivation per voice, so an edit re-renders only its section, and the
start of each section is kept beside the MP3. Speaking lives in
contrib/speak.py, apart from tts.py, so that a change to tts.py
re-renders only the sections whose text it changes. The book is read in
af_heart, am_echo, bf_emma and bf_isabella; the list is in nix/tts.nix.

With an empty cache the Pages build narrates the whole book, at about 10
minutes per voice on a 4 core runner, which outlasts the 30 minute
timeout.
Put the browser's audio player, one per rendered voice, at the top of
each chapter, so that narration works without JavaScript.
theme/narration.js replaces them with one player floating at the bottom
of the page, opened from the menu bar: play, a timeline marked at the
chapter's main sections, speed, voice, and the position where the reader
stopped. The audio is linked from the site URL, since the print page
holds every chapter at the root. The preprocessor lives apart from the
renderer, so that changing it does not re-render the book.
@bc1cindy

Copy link
Copy Markdown
Member Author

Reopened from a branch in this repository as 94: #94

@bc1cindy bc1cindy closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read-aloud for the book

1 participant