-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new option to generate subtitles by a specific number of words #1729
Add new option to generate subtitles by a specific number of words #1729
Conversation
ADD warning for max_line_width compatibility
amazing |
from pydub import AudioSegment song = AudioSegment.from_mp3("good_morning.mp3") PyDub handles time in millisecondsten_minutes = 10 * 60 * 1000 first_10_minutes = song[:ten_minutes] first_10_minutes.export("good_morning_10.mp3", format="mp3") |
@amolinasalazar which word count do you suggest for youtube? |
Actually I think that's a really personal choice and it can depend on several things. In the end, the main factor why Reels or Shorts normally have just a couple of words on the screen at a moment is because of the aspect ratio of the videos. Having long subtitle lines for videos watched in mobile phones with a vertical orientation will fill the whole screen with words. There are other factors like the font size, the speed of the speech or even the complexity of the context. Less words normally create dynamic and impactful videos, ideal for simple and strong messages, but it can be stressful if those have a long duration. For example, I won't set 1-3 words at a time if you are explaining a hard topic as it could be stressful to understand. So in my opinion, you need to find a comfortable number on your own, but something between 3-6 words can be pleasant in general. |
…penai#1729) * ADD parser for new argument --max_words_count * ADD max_words_count in words_options ADD warning for max_line_width compatibility * ADD logic for max_words_count * rename to max_words_per_line * make them kwargs * allow specifying file path by --model * black formatting --------- Co-authored-by: Jong Wook Kim <[email protected]>
…penai#1729) * ADD parser for new argument --max_words_count * ADD max_words_count in words_options ADD warning for max_line_width compatibility * ADD logic for max_words_count * rename to max_words_per_line * make them kwargs * allow specifying file path by --model * black formatting --------- Co-authored-by: Jong Wook Kim <[email protected]>
can I use this using the openai whisper API? if so, how? |
The command name is |
True, jonwook renamed this command before merging the PR. I'll update the first comment so there are no confussions. |
*Updated according jonwook code review
Added a new word option called --max_words_per_line 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_per_line 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_per_line value.
i.e. Segment = [word1, word2, word3, word4, word5] and max_words_per_line = 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_per_line 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