Repository navigation
feat: allow speaker labels for video files - #1324
Draft
tarushvkodes wants to merge 1 commit into
Draft
tarushvkodes wants to merge 1 commit into
tarushvkodes wants to merge 1 commit into
Conversation
File transcription skipped diarization whenever the file extension conformed to UTType.movie, and the UI disabled the "Label speakers" toggle for video. The diarizer (FluidAudio StreamingAudioSourceFactory) and the per-turn slicer both read the file through AVAudioFile(forReading:), which decodes only the audio track. The standard buffered path already relies on that same call for video containers, so the speaker path needs no special case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The PR Policy check is blocking this PR because required template information is missing. Please update the PR description with:
Visual files detected:
Screenshots or video are required for UI, UX, settings, onboarding, overlay, menu bar, or visual behavior changes. If this PR has no visual changes, check the no-visual-change box in the template. If this remains incomplete for 48 hours after opening, the PR may be closed. |
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.
Description
Lets File Transcription label speakers in video files (.mov, .mp4 and other
UTType.movietypes), not only audio files.Why video shouldn't affect speaker ID
Speaker identification never looks at the container. It only sees decoded audio samples:
StreamingAudioSourceFactory.makeDiskBackedSource, which callsAVAudioFile(forReading:).transcribeFileWithSpeakerLabels) opens the file again withAVAudioFile(forReading:)to slice each turn.AVAudioFilereads only the audio track of a movie file and ignores the video track. The standard (non-speaker) path in the same function already depends on that: for a video container it skipstranscribeFile(at:)and usesAVAudioFile(forReading:)with chunked reads. So every file read in the speaker path has a working equivalent for video today. The!isVideoContainercheck was the only thing turning it off.If the audio track is missing or unreadable,
transcribeFileWithSpeakerLabelsreturnsniland the existing fallback runs. The user gets an unlabeled transcript and the existing "Speaker labeling was unavailable for this file" notice, the same as for a bad audio file.Changes
FileTranscriptionServiceno longer skips diarization for video containers, and its "skipped for video container" log branch is gone.isVideoContainerstill routes video away from the provider's nativetranscribeFile(at:)path, unchanged.FileTranscriptionViewno longer disables the "Label speakers" toggle or hides the speaker-count picker for video, and drops the "Available for audio files only" caption.Type of Change
Related Issue or Discussion
Closes #1322
This change turns on a toggle that already exists for video files. It adds no new UI.
Testing
Same samples from video and audio. I took each video and copied its audio track into an .m4a without re-encoding (
ffmpeg -i in.mov -vn -c:a copy out.m4a). Then I decoded both files withAVAudioFile(forReading:), the call both speaker-path reads use, and hashed the float samples:The hashes and frame counts match, so the diarizer gets the same input either way.
Diarizer output. I ran
OfflineDiarizerManager(config: .default).process(url)from FluidAudio at the pinned revision386f719. On the 5-minute recording, the .mov and the .m4a gave identical segments: 8 segments, the same start and end times, one speaker. WithwithSpeakers(exactly: 2)the results vary from run to run on both the .mov and the .m4a, so that variation comes from clustering, not from the container.Build.
./build.sh unsignedgives** BUILD SUCCEEDED **.Manual check for reviewers. Choose a .mov with two speakers in File Transcription. "Label speakers" is now enabled. Turn it on and transcribe. The result shows Speaker 1 / Speaker 2 segments, like the same audio saved as .m4a.
swiftlint --strict --config .swiftlint.ymlon the changed files, 0 violationsmainflags too (repeatedGuard,wrapIfStatementBodies,docComments). Nothing on the changed lines.Not done: a full end-to-end run of the patched app on a video, and Intel (the speaker toggle is hidden there anyway because
SpeakerDiarizationService.isSupportedis false).Screenshots / Video
The sample-hash and diarizer output above are the evidence. A screenshot of the enabled toggle for a .mov still needs to be added.
Notes
AI use: Claude Code traced the gate, wrote the probe that compares the diarizer's input and output for video and audio files, and drafted the diff and this description.
🤖 Generated with Claude Code