bestoai commited on
Commit
80226aa
·
verified ·
1 Parent(s): c2db727

Divided by zero problem resolved

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -47,6 +47,12 @@ def generate_srt(words, audio_duration, srt_path, num_lines):
47
  segment_duration = audio_duration / (len(words) // (5 * num_lines)) # Average duration for each segment
48
  current_time = 0
49
 
 
 
 
 
 
 
50
  for i in range(0, len(words), 5 * num_lines):
51
  lines = []
52
  for j in range(num_lines):
 
47
  segment_duration = audio_duration / (len(words) // (5 * num_lines)) # Average duration for each segment
48
  current_time = 0
49
 
50
+ divisor = len(words) // (5 * num_lines)
51
+ if divisor == 0:
52
+ segment_duration = audio_duration # Use full duration as fallback
53
+ else:
54
+ segment_duration = audio_duration / divisor # Calculate duration per segment
55
+
56
  for i in range(0, len(words), 5 * num_lines):
57
  lines = []
58
  for j in range(num_lines):