Repository navigation
fix(captions): pick the spoken original on multi-audio videos; drop YouTube rolling-caption repeats - #292
Open
hass-87 wants to merge 1 commit into
Open
fix(captions): pick the spoken original on multi-audio videos; drop YouTube rolling-caption repeats#292hass-87 wants to merge 1 commit into
hass-87 wants to merge 1 commit into
Conversation
…ouTube rolling-caption repeats - select_caption: on dubbed videos YouTube lists one -orig track per audio track, so originals[0] (alphabetical) picked e.g. ar-orig for an English video. Use the -orig matching info.language; with no language, English first. - parse_vtt: YouTube auto-captions repeat the previous cue's last line (and a 10 ms cue repeats it alone), so each line appeared about three times. Drop only that carried-over line; separate cues that repeat speech are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
On YouTube videos with several audio tracks (auto-dubbed),
yt-dlplists one<lang>-origcaption track per audio track. With the default--sub-lang auto,select_captionreplaces the chosen key withoriginals[0], the alphabetically first one. For an English video with 22 dubs this gavear-orig, reported ascaptions (ar, automatic, unknown).Separately, YouTube auto-captions "roll": each cue repeats the previous cue's last line on top, and a 10 ms cue repeats it alone.
_dedupemerges only overlapping cues, and these cues touch but do not overlap. So every line appeared about three times in the transcript.Fix
select_caption: when there are several-origtracks, use the one that matchesinfo['language']. With no language, use English first (english_first), never alphabetical. Single--origbehaviour is unchanged.parse_vtt: drop only the carried-over line. That is the first line of a cue, when it equals the previous cue's last spoken line and the cue either has more lines or lasts 20 ms or less. Separate cues that repeat speech are kept (test_overlapping_prefix_only_and_mixed_karaokestill holds).Tests
test_multi_audio_dub_uses_metadata_original_not_alphabetical,test_youtube_rolling_auto_captions_are_not_repeated.-origtracks,language: en-US): nowen-orig, 574 segments, no adjacent repeats.select_captionandparse_vttexpectations re-checked. I could not run the full pytest suite in my environment, so please let CI confirm.🤖 Generated with Claude Code