Bookshelf(experiment)
Synchronized audiobook player × ebook reader — same place in both.
Synchronized audiobook player × ebook reader — same place in both.
Player above is the sync stack on a rights-clean seed (short script + two AI narrations, MMS-aligned). Switch voices; the sentence address stays put.
Syncs an audiobook to a real EPUB with its formatting, so text scrolls and
highlights sentence-by-sentence with narration. Every sentence has two
coordinates: a text address (book, chapter, paragraph, sentence) stable
across editions, and a time span on one audio file. Matching produces the
second from the first. Scroll-sync, deep links, multi-edition place-preserving
switch, playlists — all address lookups once that table exists.
Abridgments cut text; narrators ad-lib; rips have trims. Matching is a full outer join:
Text with no audio partner → unvoiced. Audio with no text partner →
unmatchedAudio (narrator intros, credits). Both are first-class rows.
(5,1,3) exists in the text but is never narrated; the first 40 seconds of audio exist but match no sentence. Tolerance, sparse, and structural align regimes decide how aggressively the join insists on partners.TorchAudio MMS forced alignment walks the book in 300-word batches with a
60-word lookahead, anchored at the end of the last mapped sentence. An EMA of
frames_per_char predicts next-span length; a monotonic clamp forbids starting
before the anchor. Word timings cut sentence spans, then discard.
Every alignment embeds a content-hash of the text it aligned against.
align qa checks monotonicity, duration sanity, and rate residuals. align doctor probes chapters with distinctive sentences to localize failure.
Doctor originally reused CTC inside an unanchored wide window. Viterbi spreads a short target across lookalike fragments and reports a great score for doing so — a 38-character sentence “placed” across 1,537 seconds at score 0.95.
Fix (scan_range): slide subwindows of ~2.5× expected duration D at
0.5×D stride; reject placements longer than 3×D; keep best valid score.
Escalation widens the scanned range; the model still sees only the subwindow.
_align_window verified correct in tight windows. It was geometry: give Viterbi room to smear and it will.QA after every alignment. When residuals look wrong, doctor drops distinctive-sentence probes (corpus IDF) across the chapter, places each independently against cached emissions, and reads Δ = found − expected: constant shift, growing rate drift, missing audio, wrong edition.
heal re-places damaged regions and cascade-nudges neighbors rather than
re-running full-chapter alignment. Alignments are content-addressed sidecars —
coordinates only. Audio and book text stay with the user.