hivecorp commited on
Commit
7b61720
·
verified ·
1 Parent(s): 0a64399

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -32,9 +32,9 @@ def generate_srt(words, audio_duration, srt_path):
32
  segment_duration = audio_duration / (len(words) // 16) # Average duration for each 16 words
33
  current_time = 0
34
 
35
- for i in range(0, len(words), 16): # Every 16 words for two lines
36
- line1 = ' '.join(words[i:i + 8]) # First line with up to 8 words
37
- line2 = ' '.join(words[i + 8:i + 16]) # Second line with the next 8 words
38
 
39
  if line2.strip() == '':
40
  line2 = '' # Handle case where there aren't enough words for the second line
@@ -44,7 +44,7 @@ def generate_srt(words, audio_duration, srt_path):
44
 
45
  start_time_str = format_srt_time(start_time)
46
  end_time_str = format_srt_time(end_time)
47
- srt_file.write(f"{i // 16 + 1}\n{start_time_str} --> {end_time_str}\n{line1}\n{line2}\n\n")
48
 
49
  current_time += segment_duration # Update current time for the next segment
50
 
 
32
  segment_duration = audio_duration / (len(words) // 16) # Average duration for each 16 words
33
  current_time = 0
34
 
35
+ for i in range(0, len(words), 22): # Every 16 words for two lines
36
+ line1 = ' '.join(words[i:i + 10]) # First line with up to 8 words
37
+ line2 = ' '.join(words[i + 12:i + 22]) # Second line with the next 8 words
38
 
39
  if line2.strip() == '':
40
  line2 = '' # Handle case where there aren't enough words for the second line
 
44
 
45
  start_time_str = format_srt_time(start_time)
46
  end_time_str = format_srt_time(end_time)
47
+ srt_file.write(f"{i // 22 + 1}\n{start_time_str} --> {end_time_str}\n{line1}\n{line2}\n\n")
48
 
49
  current_time += segment_duration # Update current time for the next segment
50