Add new option to generate subtitles by a specific number of words #548
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.
Added a new word option called --max_words_count that will generate subtitles setting a maximum limit of words per segment.
I've opened the same PR in Whisper: https://github.com/openai/whisper/pull/1729 with some slightly changes:
The rest is just a copy/paste of the original PR description:
Added a new word option called --max_words_count that will generate subtitles setting a maximum limit of words per segment. This could sound similar to --max_line_width option, but the results are more pleasent for readers IMHO. Here a couple of comparisons using .SRT files:
Notice that --max_words_count works as an upper bound of words, but still it will respect the segments in the way that end of sentences can have less words if the remaining number of words in a segment is lower than the max_words_count value.
i.e. Segment = [word1, word2, word3, word4, word5] and max_words_count = 3
=>Result = [word1, word2, word3] and [word4, word5]
This is not the behaviour we can see using --max_line_width that can leave bigger gaps of time when joining end and beginning of segments:
Subtitles generated with --max_words_count look similar of what we can see in Shorts, Reels and other short duration videos.
This is my first contribution, so feel free of changing/comment/improve anything.
Additional notes
This is my first contribution, so feel free of changing/comment/improve anything.