Skip to content

Keep the transcript when speakers can't be labelled on import or recovery - #37

Merged
billlyzhaoyh merged 3 commits into
mainfrom
fix/35-speakers-fallback
Nov 26, 2026
Merged

billlyzhaoyh merged 3 commits into
mainfrom
fix/35-speakers-fallback

Conversation

@billlyzhaoyh

@billlyzhaoyh billlyzhaoyh commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #35.

What changed

With Detect speakers on, transcribe (app/src-tauri/src/commands.rs) resolved models with diarization. So import and crash recovery failed before transcribing when the speaker-detection pack wasn't installed, and showed the resolver's list of missing files. A diarization error after transcription also threw the finished transcript away.

  • Missing speaker models, or a failure to load or run them, no longer stop transcription. transcribe resolves the transcription models only, then labels speakers as a separate step. If that step fails, the transcript is kept, without speakers and with a note saying why.
  • Import, recovery and Stop share one labelling step and one result.
    • speaker_engine builds the speaker engine, which checks for the speaker models. label_speakers runs it. Together they replace Stop's private copy, and Stop builds the engine before it reads the recording.
    • finish_transcript builds the result for all three. It labels speakers if asked, applies the vocabulary file, reports progress and turns a labelling error into the note.
    • NewTranscript (transcript, speakersLabelled, note) replaces StoppedRecording.
  • A missing pack gets a plain note: "The speaker-detection pack isn't installed, so this transcript has no speakers. Add it on the Models page." The resolver puts every verified pack's files into one folder, so the speaker models are in the transcription folder only when their pack is installed. When they aren't, the engine's "model not found" error becomes this note. Other failures keep Stop's existing note: "Speakers couldn't be labelled, so this transcript has none. (…)". Stop now shows the plain note too.
  • App: imports and recoveries open from the result's speakersLabelled and show its note. A recovery puts the note after its usual "Recovered from a recording that had no transcript…". openNewTranscript takes the whole result, and FinishedRecording extends NewTranscript.
  • The resolver wrappers lose their diarize flag, which every caller now sets to false.

Not in this PR:

  • A speaker pack that fails to unpack still stops transcription: A speaker pack that fails to unpack still stops transcription #38. The resolver unpacks every verified pack into one folder on the first run after the packs change, and an error there stops transcription, with speakers on or off. That's already the case on main; fixing it means changing how packs are cached.
  • Showing on the Detect speakers option that the pack isn't installed. It needs a clickable prototype first (prototype-first rule).
  • engine::process is unchanged. The app no longer calls it, but the command-line example still fails outright on a diarization error.
  • A Rust test of the speaker step. speaker_engine and label_speakers don't need an AppHandle, so it's practical, but it wasn't one of the agreed tests.

Reviews

Codex

Two P2 findings, both addressed in the second commit:

  • Stop read the whole recording before finding the speaker pack missing, about 230 MB of memory per hour of audio. On main, resolving with speakers on failed before the audio was read. Fixed: Stop builds the speaker engine, which checks for the models, before reading the recording.
  • A speaker pack that fails to unpack still blocks import and recovery. Already the case on main, so it's filed as A speaker pack that fails to unpack still stops transcription #38. The code comment and this description no longer claim otherwise.

/simplify

The third commit changes no behaviour:

  • Fixed:
    • A duplicate model-file check.
    • Result-building duplicated between import and Stop; the speaker-less transcript is now built only when it's used.
    • A hardcoded 0.95 progress point.
    • The unused diarize flag.
    • Positional unpacking of the result in the app.
  • Skipped:
    • One shared pipeline in the engine: outside this PR.
    • Stop checking every pack's signature again when it finishes: already on main, and changing it changes what happens if a pack is removed mid-recording.
    • Working out "has speakers" from the transcript: it changes the result format the app reads.

Tests

The two tests agreed on #35, in app/src/App.test.tsx, both failed before the fix (segments is not iterable, no note) and pass now:

  • An import with speakers on, where transcribe returns a transcript and a note: it opens without speakers, shows the note, and saves diarized: false.
  • A recovery in the same situation: it opens with the recovered note followed by the speaker note, and the recording leaves the interrupted list.

The default transcribe mock now returns the new result shape; no assertions changed.

  • app: 113 passed, typecheck clean
  • app backend (Rust): 61 passed, cargo check --all-targets with no warnings

Verified in the desktop app

tauri dev on macOS, with KINDTECH_MODELS_DIR pointing at a models folder that has no speaker-detection models:

  1. Planted a bench clip as an interrupted recording.
  2. Ticked Detect and label speakers on the Import page.
  3. Pressed Recover transcript.

The transcript opened in paragraph mode with the note "Recovered from a recording that had no transcript. The last moment of audio may be missing. The speaker-detection pack isn't installed, so this transcript has no speakers. Add it on the Models page." The saved session has diarized: false and all 44 words, and the recording left the interrupted list.

Runs after the Codex fixes and after /simplify gave the same result. The last run checks that the engine's "model not found" error becomes the plain note.

The app was driven through Accessibility only, without keystrokes. Three paths weren't driven:

  • Stop with speakers on: it would record from the microphone. Its change (checking for the models before reading the recording) is covered by reading the code and cargo check.
  • Import through the file picker: the picker needs keystrokes. Recovery runs the same transcribe command.
  • Successful labelling: there are no speaker-detection models on this machine.

…rt or recovery

With Detect speakers on, `transcribe` resolved models with diarization, so
import and crash recovery failed before transcribing when the speaker-
detection pack wasn't installed, showing the resolver's file list. A
diarization error after transcription also threw the transcript away.

`transcribe` now resolves the transcription models only and labels speakers
as a separate step, shared with Stop (`label_speakers`). If labelling fails,
the transcript comes back without speakers and with a note, in the same
shape Stop returns (`NewTranscript`). A missing pack gets a plain note:
"The speaker-detection pack isn't installed, so this transcript has no
speakers. Add it on the Models page." Stop shows that note too now.

The app opens imports and recoveries from the result's `speakersLabelled`
and shows its note; a recovery puts it after the usual recovered note.

Closes #35
From a Codex review of #37.

Stop resolved the models, read the whole recording, and only then found
the speaker models missing, holding about 230 MB per hour of audio just
to return the note. On main, resolving with speakers on failed before
the audio was read. `speaker_engine` now checks for the models and builds
the engine; `label_speakers` runs it. Stop calls the first before reading
the recording.

The comment on `transcribe` no longer claims a failing speaker pack can't
cost the transcript: resolving still unpacks every verified pack, so one
that fails to unpack stops transcription (#38, already the case on main).
From /simplify on #37; behaviour is unchanged.

- `finish_transcript` builds the result for Import, recovery and Stop:
  labels speakers if asked, applies the vocabulary file, reports progress
  (at engine::PROGRESS_TRANSCRIBE_END, not a literal 0.95) and turns a
  labelling error into the note. The speaker-less transcript is built
  only when it's used.
- `speaker_engine` no longer checks for the speaker models itself:
  `SherpaEngine::new` already does, and its ModelNotFound becomes the
  "pack isn't installed" note. The speaker step passes anyhow errors up
  (anyhow was already in the tree through `engine`).
- `resolve_models_dir` and `resolve_verified_models_dir` lose their
  `diarize` flag, which every caller set to false. The resolver's doc
  says the app relies on its folder holding every verified pack (#38).
- App: `FinishedRecording` extends `NewTranscript`, and
  `openNewTranscript` takes the result instead of six arguments.
@billlyzhaoyh
billlyzhaoyh merged commit 62b1cd8 into main Nov 26, 2026
12 checks passed
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.

Import and crash recovery fail outright when speaker detection is on but its pack isn't installed

1 participant