Repository navigation
Add optional speaker labeling (diarization) to file transcription - #378
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f20929f1f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| samples = try self.readSamples( | ||
| from: audioFile, | ||
| startSeconds: turn.startSeconds, | ||
| endSeconds: turn.endSeconds, | ||
| minimumDurationSeconds: 1.1 |
There was a problem hiding this comment.
Split overlong diarized turns before ASR
When a diarized turn spans a long monologue or single-speaker section, this path reads turn.startSeconds...turn.endSeconds into one sample array and sends it to provider.transcribe as a single request. The standard file path explicitly chunks at 20 minutes to avoid model/input and memory limits, but the diarized path only limits merging adjacent turns and never splits an individual long turn; if that ASR call fails, the segment is skipped and a partial transcript can still be returned. Split speaker turns into the same bounded chunks before reading/transcribing them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f20929f1f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| samples = try self.readSamples( | ||
| from: audioFile, | ||
| startSeconds: turn.startSeconds, | ||
| endSeconds: turn.endSeconds, | ||
| minimumDurationSeconds: 1.1 |
There was a problem hiding this comment.
Split overlong diarized turns before ASR
When a diarized turn spans a long monologue or single-speaker section, this path reads turn.startSeconds...turn.endSeconds into one sample array and sends it to provider.transcribe as a single request. The standard file path explicitly chunks at 20 minutes to avoid model/input and memory limits, but the diarized path only limits merging adjacent turns and never splits an individual long turn; if that ASR call fails, the segment is skipped and a partial transcript can still be returned. Split speaker turns into the same bounded chunks before reading/transcribing them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2f1b8b831
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if end - start < minimumDurationSeconds { | ||
| let deficit = minimumDurationSeconds - (end - start) | ||
| start = max(0, start - deficit / 2) | ||
| end = min(fileDurationSeconds, start + minimumDurationSeconds) | ||
| start = max(0, end - minimumDurationSeconds) |
There was a problem hiding this comment.
Avoid expanding short speaker turns into neighbors
When the diarizer emits a turn shorter than 1.1s adjacent to another speaker, this widens the audio window before/after the turn rather than padding with silence. The resulting samples can include neighboring speech, but the transcript is still stored under the original turn.speakerLabel, so short back-and-forth sections can duplicate words or attribute them to the wrong speaker even though the diarizer boundaries were correct.
Useful? React with 👍 / 👎.
13ae2da to
e49cdd9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e49cdd92da
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e49cdd9 to
c1a7bf0
Compare
|
Rebased onto 1.6.0. No conflicts, the diarization changes are unchanged. xcodebuild and swiftlint --strict both pass. Ready to pull. |
Adds a "Label speakers" toggle to File Transcription that attributes the transcript to "Speaker 1", "Speaker 2", ... using the offline diarizer already present in the FluidAudio dependency (no new deps). - Diarize-first pipeline: identify speaker turns via the memory-mapped offline diarizer, then transcribe each turn's audio slice with the active provider - works with any TranscriptionProvider since it only needs transcribe(samples) - Optional "Number of speakers" hint (Auto/2-8) feeds the diarizer's clustering constraints for better accuracy when the count is known - Speaker-labeled segments with timestamps in the results view; labeled text flows to copy/history/text export; JSON export gains structured segments (backward-compatible decoding for existing history) - Diarizer CoreML models auto-download on first use via FluidAudio's own download flow - Any diarization failure falls back to the standard transcription paths, so baseline behavior is never at risk - arch(arm64)-gated like FluidAudioProvider; the toggle is hidden on Intel where FluidAudio is unavailable Addresses altic-dev#18 (file transcription scope; live dictation out of scope). Co-Authored-By: Claude Fable 5 <[email protected]>
Addresses Codex review findings on the speaker-labeling path: - Fall back to full-file transcription on any per-turn read/ASR failure instead of returning a transcript with silent gaps - a failed slice no longer leaves a hole while other slices succeed, preserving the "baseline behavior is never at risk" guarantee. - Split overlong speaker turns into 20-minute chunks before ASR (mirrors the standard path), so a long single-speaker stretch never exceeds the model input limit. - Persist speakerSegments in file transcription history so labeled transcripts keep their structured speaker/timestamp data across navigation and restart, and JSON export from history includes the segments (backward-compatible decoding for existing entries). - Include the new speaker-labeling settings keys in the settings backup payload so Export/Import no longer drops them. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Addresses Codex review: widening a sub-minimum speaker turn's audio window pulled in neighboring speech, so a short turn could absorb an adjacent speaker's words (duplication / wrong attribution) even when the diarizer boundaries were correct. Read only the turn's own audio and pad with trailing silence to the ASR input minimum, keeping each segment single-speaker. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The speaker-labeled path added a second, subtly different copy of the resampling helper. It built its own AVAudioConverter and never set `downmix`, so a multi-channel source was channel-mapped rather than mixed: only the left channel reached the ASR and the right one was silently dropped. The standard file-transcription path in this same file already calls AudioBufferConverter.monoSamples, which sets `downmix` and has tests. The copy is deleted and the call delegated there — 75 lines removed, no new behaviour. Verified by feeding a stereo file with different speech on each channel: before the fix the transcript held only the left channel, and swapping the channels swapped the output. After it, both orderings produce identical output, which is what mixing means. Stereo sources are common — in one real-world archive of 164 recordings, 72 were stereo. Mixing is the right default over dropping half the content, but it does destroy an exact separation when the channels genuinely hold different speakers. That case is worth surfacing to the user later; silently transcribing half the file is not. Also adds SpeakerTurnMergingTests, which pins down mergeAdjacentTurns: same-speaker merging across short gaps, the gap boundary, the 20-minute cap, and the consequence that matters — when clustering collapses to one label, the merge welds question and answer into a single segment. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Only the lines this branch introduces: the SpeakerTranscriptSegment id property, the speaker-count Picker range, and the two new files. The pre-existing violations in these files are left alone so the diff stays about diarization. swiftlint --strict reports no violations; swiftformat now flags exactly the 15 findings main already had. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
I've been running this branch against real recordings and wanted to share two things: a defect I found, and an offer. The speaker-labeled path discards the right channel of stereo files
What makes it easy to miss: the standard file-transcription path in the same file already calls I found it by feeding a stereo file with different speech on each channel: the transcript held only the left channel, and swapping the channels swapped the output. Stereo is common enough to matter — in my own archive, 72 of 164 recordings are stereo. The fix is to delete the local copy and delegate to One tradeoff worth stating: mixing is the right default over dropping half the content, but it destroys an exact separation when the channels genuinely hold different speakers. Surfacing that to the user is worth doing separately — silently transcribing half the file is not. The offerThe branch has drifted: Branch: https://github.com/Erik5000/FluidVoice/tree/diarization-rebased
It's your PR, so it's your call. Happy to:
Whichever you prefer — I mainly want the feature to land. @altic-dev this is anchored to #18 if it helps with triage. |
Placed in .github/screenshots/ alongside the existing ones, so the PR body can reference them by raw URL and they survive independently of a comment. Captured against this branch with an 80-second public-domain excerpt from a LibriVox dramatic reading — deliberately not a real recording, since a screenshot publishes whatever words are on screen. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
c1a7bf0 to
b040f06
Compare
|
Thanks @Erik5000. I updated this PR from your rebased branch, preserving the three original commits' authorship and your follow-up commits. The update keeps your stereo downmix fix, merge tests, formatting, and screenshots. I also disabled speaker labeling for video containers, added a visible notice and progress reset when audio diarization falls back, preserved timestamps in copied/history/exported text, and made the shared audio converter explicitly nonisolated. For the provider-window review feedback, Cohere and Nemotron already split long input internally at energy-aware boundaries, so the outer 20-minute speaker-turn split remains a memory bound instead of adding hard model-window cuts. Validated with strict SwiftLint and 15 focused downmix, resampling, speaker-turn, and timestamp-formatting tests. The PR is now rebased on current |
Greptile SummaryThe PR adds optional offline speaker labeling to file transcription, preserving speaker metadata through history and export while falling back to ordinary transcription when labeling cannot produce a complete result.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a844cb9759
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| let labeledText = segments | ||
| .map { "\($0.speaker): \($0.text)" } |
There was a problem hiding this comment.
Include timestamps in labeled plain text
When a speaker-labeled result is copied, viewed from history, or exported as .txt, those paths consume result.text, but this mapping records only the speaker and transcript. Consequently, the timestamps shown in the result UI and retained in speakerSegments disappear from these outputs, so users cannot preserve the displayed chronology outside the app; include each segment's timestamp here or format speakerSegments in those output paths.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9ea5941. Speaker segment formatting now owns a shared timestamp representation, labeled plain text includes that timestamp, and the result UI reuses the same formatter. Copy, history text, and text export therefore preserve the displayed chronology. Added focused minute and hour formatting tests.
altic-dev
left a comment
There was a problem hiding this comment.
Reviewed the diarization pipeline, provider chunking, audio slicing/downmix, fallback behavior, persistence/backward compatibility, export, and future meeting-transcription fit. This is a sound offline file-transcription foundation. All required checks are green.
Description
Adds optional offline speaker labeling to file transcription, following the accepted direction in #18.
Type of Change
Related Issue or Discussion
Addresses #18.
Testing
swiftlint --strict --config .swiftlint.yml Sourcesswiftformat --config .swiftformat SourcesScreenshots / Video
Speaker-label controls
Speaker-labeled result
Progress state
Notes
Speaker diarization runs locally and downloads its FluidAudio models on first use. Live dictation diarization remains out of scope.
The rebase, stereo fix, merge tests, and screenshots were contributed by @Erik5000. The original feature commits retain their original authorship.