Repository navigation
Add AI Transcription/Read Along - #156
Draft
KeinNiemand wants to merge 35 commits into
Draft
KeinNiemand wants to merge 35 commits into
KeinNiemand wants to merge 35 commits into
Conversation
Owner
|
I'm away at the moment but I'll take a gander at this when I get home. Looks cool though. |
Owner
|
wow this is incredible. I haven't gone through all the code yet but so far it's working as expected. good work man. I'm going to keep going through it |
Owner
|
Initial thoughts:
|
Contributor
Author
|
should be done except the alignment thing since I don't know what alignment you want or how to make that better. |
Windows Media Foundation causes 30-second freezes when opening or seeking large .m4b files — the same freeze reproduces in Windows Media Player itself. VLC opens the same files instantly. Replace the audio backend with LibVLCSharp + VideoLAN.LibVLC.Windows: - LibVLC runs its own threaded demuxer/decoder, bypassing WMF entirely - Remove hidden MediaPlayerElement from PlayerControlGrid and LegacyPlayerPage - Add public Play(), Pause(), NaturalDuration on PlayerViewModel so external callers no longer reference the player backend directly - EndReached dispatches to UI thread to avoid LibVLC deadlock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ut all on OnTimeChanged on the main thread via dispatcher queue.
Ignore stale time updates while a new VLC media is opening, and keep chapter/seek UI updates explicit without bringing back the broad SyncPlaybackState refactor.
… use samplerate resampler to fix stutter caused by speex
- OnPlaying skipped HandleMediaOpened whenever the play icon already showed Pause (auto-advance fires Playing -> EndReached -> Playing with no Paused in between), leaving _mediaJustOpened stuck: time/progress updates froze and every later OpenAudiobook/OpenSourceFile silently no-oped until restart. - _pendingAutoPlay is now owned by OpenSourceFile (autoPlay parameter) and is cleared when an open fails or errors, so a stale flag can't autoplay an unrelated open later. - CurrentPosition/NaturalDuration returned 0 while VLC reports -1 (Ended or Stopped): skip-forward at end of book seeked to 0 and persisted it, wiping the saved position. Fall back to the stored position / parsed media duration. - Volume set before the first audio output exists can be ignored by libvlc; re-apply it on media open (same as the playback rate). - Pause/stop the load-triggered playback when the audiobook was closed or has no chapters while its media was still opening (audio kept playing behind the error dialog). - Gate the per-tick progress save to one in-flight upsert and capture the audiobook reference so a mid-save NowPlaying change can't NRE on a background thread. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
…23.1 Latest stable releases; neither introduces new dependencies for this target. Note: 3.10.0 moved the UWP/WinUI VideoView targets into separate packages, so the app now consumes the plain net8.0 assembly - Audibly is audio-only and uses no VideoView, and automatic libvlc discovery (Core.EnsureLoaded) is in the shared code path, unchanged. 3.9.7 also added win-arm64 lookup with a win-x64 fallback for the native libraries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Foundation for AI read-along transcription (upstream issue rstewa#146): - TranscriptSegment (one sentence: chapter/source-file index, absolute-in-file StartMs/EndMs, text, packed per-word karaoke timings via WordTimingCodec) - TranscriptChapterStatus (per book x chapter transcription state/progress, producing model id, last error) - Chapters are keyed by their stable integer index so transcripts survive re-imports; rows cascade-delete with the audiobook. - ITranscriptRepository/SqlTranscriptRepository: chapter/book reads, bulk segment inserts, targeted status updates (ExecuteUpdate), atomic chapter-completion flush, per-book LIKE search, and startup recovery that purges partial segments of chapters left InProgress by a crash. - AddTranscripts EF migration; applied automatically by the existing startup migration check. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
- SpeechModelDescriptor: backend-agnostic description of a downloadable speech model (files, sizes, sample rate, license); Parakeet TDT 0.6B v3 int8 descriptor pointing at the sherpa-onnx asr-models GitHub release. - TranscriptionModelService: streams the ~490 MB archive with Range-resume from a .partial file, free-space pre-check, SharpCompress tar.bz2 extraction (skipping test_wavs), size-verified model.json manifest, delete support. Model lives in LocalState\Models\<id>. - Settings: new "AI Read-Along" section (enable toggle, model card with progress/cancel/delete, automatic-transcription scope, license & attribution links). Disabled on x86 (the int8 encoder cannot fit a 32-bit address space). - UserSettings: TranscriptionEnabled, TranscriptionScope, IsTranscriptPaneOpen. - Manifest: internetClient capability (first runtime download in the app). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
The speech runtime is fully decoupled from the app layer: - ISpeechToTextBackend + TimedWord: backends turn PCM windows into timed words; token semantics never leak upward, so models/runtimes are swappable. - SherpaOnnxParakeetBackend: the only sherpa-aware class (OfflineRecognizer, nemo_transducer, cpu, threads clamped to half the cores); assembles subword tokens into words, deriving end times from timestamp gaps. - IPcmAudioExtractor / LibVlcPcmAudioExtractor: decodes chapter ranges to 16 kHz mono PCM via a LibVLC :sout transcode into temp WAVs (own LibVLC instance, never the player's), served window-by-window; ranges are split into 30-minute blocks to bound temp file size. This seam allows a no-VLC decoder later. - OverlapStitcher: 40 s windows / 5 s overlap; cuts mid-run of matching words (start times within 400 ms), falling back to the largest silence at the overlap midpoint. - SentenceAssembler: punctuation-driven sentence grouping with 350-char/30-s hard caps (keeps the word-timing codec in ushort range) and paragraph detection from >=1.5 s gaps. - ChapterTranscriber: block/window loop with incremental segment flushes and an atomic Completed flush; checks cancellation/preemption between windows. - TranscriptionCoordinator (minimal): manual per-book queue, status transitions, failure notifications, 60 s idle unload of model + decoder; playback-aware priorities land in the next slice. - Library tile gains "Transcribe now"; coordinator wired in App.OnLaunched and cancelled on window close. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
The coordinator now re-picks after every chapter, strictly ordered:
current chapter of the playing book -> its later chapters -> its earlier
chapters -> manually requested books (FIFO, retries Failed, works with
scope Off) -> with scope "entire library": unfinished books most recently
played first (starting at their current chapter, wrapping) -> finished
books. Playback movement (NowPlaying/CurrentChapterIndex PropertyChanged)
preempts the in-flight chapter at the next window boundary when it is no
longer the top pick; preempted/cancelled chapters have their partial rows
purged and are re-queued. An in-memory status cache keeps picking and
preemption checks off the database hot path. Book-completion and
first-failure notifications; live activity line surfaced on the settings
page ("Transcribing <book> - chapter 3 of 12 (45%)").
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
- TranscriptPane (acrylic surface beside the cover art, toggle button / Ctrl+T, state persisted): virtualized ItemsRepeater sentence list with chapter header + status line, live "Transcribing..." tail row while the chapter is in progress, and full-pane placeholders for unsupported/disabled/model-missing/queued/failed states. - TranscriptViewModel: loads the playing chapter's sentences off the UI thread, follows playback with an amortized O(1) sentence cursor (binary search after seeks), appends live rows from SegmentsFlushed, tap-to-seek (cross-file via OpenSourceFile), auto-scroll suspension when the user scrolls with a return-to-position chip. - Word karaoke: one reused TextHighlighter on the active sentence's realized TextBlock, char ranges from the packed word timings (decoded lazily for the active sentence only). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Debounced (300 ms) case-insensitive search across the whole playing book via the repository LIKE query, with a hit counter and next/previous navigation (Enter = next, Esc = clear). Hits in other chapters load that chapter into the pane and suspend playback-following; the return-to-position chip (or clearing the search) reloads the playing chapter. Playback tracking is now guarded to only run while the pane shows the playing chapter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
- ImportedAudiobook gains an optional Transcript payload (portable DTOs with flat word-timing quads, codec-agnostic); System.Text.Json ignores the member on both sides, so old files import into new builds and new files import into old builds unchanged. - Export switches the anonymous projection to typed ImportedAudiobook (identical JSON member names) and asks once whether to embed transcripts when any finished chapters exist. - Import validates each chapter against the re-parsed book (index/source file layout), replaces existing rows idempotently, and never fails the book import on a bad transcript payload. Completed chapters import atomically with their status. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
VLC's native mp4 demuxer cannot combine :start-time with :sout on these
m4bs ("Timestamp conversion failed: no reference clock"): most offsets
produce an EMPTY wav (chapters failed with EndOfStreamException in bursts,
the first attempt burning a full decode pass first), and the chapters that
did produce audio are not trustworthy about WHERE that audio came from.
Reproduced outside the app with a minimal LibVLCSharp harness: every
start-time > ~0 returned 0 bytes; with :demux=avformat every offset from
41 s to 7.5 h returns exactly the requested range in ~0.2 s.
Force :demux=avformat for extraction — the same demuxer override playback
uses for these files, so transcript timestamps now share the player's seek
semantics. Also surface empty/truncated decodes as PcmExtractionException
(a near-empty wav for a non-trivial range previously either crashed the
WAV parser or let a chapter complete with zero segments), which also
covers the few-second-chapter race.
Existing transcript rows created before this fix are unreliable and should
be wiped so affected chapters re-transcribe.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Feedback: the side pane wasted the stage — 80% cover art, transcript in a strip. With the pane open the transcript now fills the whole area above the play bar and the cover shrinks to a 132px tile in the top-left corner; closing the pane restores the classic centered 300px cover. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Closing the app mid-chapter discarded the already-persisted half of the chapter: startup recovery purged partial segments of InProgress chapters and re-queued them from zero (a deliberate shortcut noted in the plan). With 30-40 minute chapters that throws away real work on every app close. Now the flushed sentences are kept everywhere (startup recovery, preemption, cancellation) and the next run resumes from the last persisted sentence: transcription restarts one second before the resume point for left context, a seam filter drops re-transcribed words that are already stored, the sentence assembler is seeded with the previous sentence end so paragraph detection stays correct across the seam, and progress is reported over the whole chapter. Chapters transcribed by a different model still redo from scratch, as do Failed retries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
ProcessorCount - 1 oversubscribes Intel hybrid CPUs with an SoC-tile low-power island (Meteor/Arrow Lake): the LP-E cores are counted but stay parked during normal use and share the efficiency class of regular E-cores. They are, however, the only logical processors without an L3 relation, so automatic mode now counts processors participating in an L3 cache group (GetLogicalProcessorInformationEx/RelationCache) and uses that minus one — e.g. 11 threads on a 14-logical Meteor Lake U (12 with L3). Systems without cache topology (VMs) fall back to max(count - 4, count / 2). A "Processor threads" setting (0 = automatic) overrides everything for hardware the heuristic misjudges, applied on the next model load. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
- Exit crash ("unhandled win32 exception" after closing mid-transcription):
the Closing handler only cancelled a token observed between windows, so
the process exited while sherpa/onnxruntime was mid-decode (and possibly
a live VLC transcode). The close is now held (Cancel + re-close) until
StopAndUnloadAsync finishes, bounded to 8 s so a hung decode can never
block exit.
- Word karaoke was stuck on the first word: TextBlock does not repaint
when an attached TextHighlighter's Ranges mutate — detach/re-attach the
highlighter on every word change.
- Tap-to-seek did nothing: ItemsRepeater does not set DataContext for
x:Bind templates (same reason Watched Folders uses Tag) — the sentence
now travels via Tag="{x:Bind}".
- The focused search result is highlighted (goldenrod row, cleared when
the search is cleared or the hit moves).
- Thread count: drop the L3 topology probe per feedback; automatic is
simply max(count - 4, count / 2), manual override unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Switching books repeatedly crashed with a stowed-exception fail-fast (0xc000027b in CoreMessagingXP): every PlayerPage navigation created a new TranscriptPane whose constructor subscribed to the app-lifetime view model's events and never unsubscribed, so stale pane instances kept driving ItemsRepeater.GetOrCreateElement/StartBringIntoView on unloaded visual trees from inside dispatcher callbacks, where XAML's UnhandledException cannot observe the throw. - Subscribe on Loaded / unsubscribe on Unloaded; scroll handlers now bounds-check against the current sentence list, no-op when unloaded, and log instead of crashing on layout-timing exceptions. - Dedupe live segment flushes that race a chapter reload (the DB read may already contain the flushed rows). - Log AppDomain unhandled exceptions and unobserved task faults to Audibly.log so dispatcher-side fail-fasts leave a stack next time. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
Newly introduced dependencies, so start on the latest stable releases. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
The pane was declared after the toggle button in the RelativePanel and covered it while open; anchor the pane below the toggle instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
The app fail-fasted with "Layout cycle detected" (0xC000027B reported from XAML's dispatcher timer): StartBringIntoView plus forced GetOrCreateElement realization was re-invalidating layout against ItemsRepeater virtualization and live row appends until XAML gave up. Auto-scroll and search jumps now only move the ScrollViewer offset via ChangeView — realized targets are positioned exactly (and skipped when already near the desired spot), unrealized ones get a proportional jump that the next active-sentence tick refines. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
- Settings: "Read-along text" card with font family (curated list) and font size; applied via property inheritance on the pane's ScrollViewer. - Fix cover art not loading back in when toggling the read-along pane: an ImageBrush discards its content while its element is collapsed and does not repaint on re-show, so the source is re-set on every toggle. - Audiobook context menu: fully transcribed books now offer "Delete transcript" in place of "Transcribe now" (confirmation dialog; a running chapter of that book yields at its window boundary before deletion; the audiobook itself is untouched). - Remove the duplicated "Transcribing... x%" message: the live tail row is now a spinner only, the chapter header keeps the status text. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cFbknrBW86oMciZw5WDQV
KeinNiemand
force-pushed
the
feature/read-along
branch
from
July 9, 2026 08:14
c08064a to
4c68017
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've implemented a very much still work and progress, implementation for AI transcription It runs fully local and produces a synced read-along view. Posting as a draft for early feedback — lots still to test and polish.
What's included:
Notes / not done yet:
I'll put this up as a draft for now to ask for some feedback figure out if this approch is ok, or if I have to do major changes.
fixes #146