Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -220,9 +220,9 @@ async def transcript_to_speech(transcript_text, voice, rate, pitch):
|
|
| 220 |
intended_start_time = start_time
|
| 221 |
|
| 222 |
if i > 0:
|
| 223 |
-
|
| 224 |
-
if
|
| 225 |
-
prev_h, prev_m, prev_s, prev_ms =
|
| 226 |
previous_start_time_ms = (
|
| 227 |
int(prev_h) * 3600000 +
|
| 228 |
int(prev_m) * 60000 +
|
|
@@ -230,12 +230,13 @@ async def transcript_to_speech(transcript_text, voice, rate, pitch):
|
|
| 230 |
int(prev_ms)
|
| 231 |
)
|
| 232 |
time_difference = start_time - previous_start_time_ms
|
| 233 |
-
|
| 234 |
-
if current_audio_duration > time_difference
|
| 235 |
-
intended_start_time = previous_end_time_ms
|
|
|
|
| 236 |
|
| 237 |
timed_audio_segments.append({'start': intended_start_time, 'audio': combined_line_audio})
|
| 238 |
-
previous_end_time_ms = intended_start_time + current_audio_duration
|
| 239 |
max_end_time_ms = max(max_end_time_ms, previous_end_time_ms)
|
| 240 |
elif audio_paths:
|
| 241 |
for path in audio_paths:
|
|
@@ -310,4 +311,3 @@ async def create_demo():
|
|
| 310 |
if __name__ == "__main__":
|
| 311 |
demo = asyncio.run(create_demo())
|
| 312 |
demo.launch()
|
| 313 |
-
|
|
|
|
| 220 |
intended_start_time = start_time
|
| 221 |
|
| 222 |
if i > 0:
|
| 223 |
+
prev_line_match = re.match(r'(\d{2}):(\d{2}):(\d{2}),(\d{3})\s+.*', lines[i-1])
|
| 224 |
+
if prev_line_match:
|
| 225 |
+
prev_h, prev_m, prev_s, prev_ms = prev_line_match.groups()
|
| 226 |
previous_start_time_ms = (
|
| 227 |
int(prev_h) * 3600000 +
|
| 228 |
int(prev_m) * 60000 +
|
|
|
|
| 230 |
int(prev_ms)
|
| 231 |
)
|
| 232 |
time_difference = start_time - previous_start_time_ms
|
| 233 |
+
# print(f"current_audio_duration:{current_audio_duration}, time_difference:{time_difference}, previous_end_time_ms:{previous_end_time_ms}, start_time:{start_time}")
|
| 234 |
+
if current_audio_duration > time_difference:
|
| 235 |
+
intended_start_time = previous_end_time_ms
|
| 236 |
+
# print(f"intended_start_time:{intended_start_time}")
|
| 237 |
|
| 238 |
timed_audio_segments.append({'start': intended_start_time, 'audio': combined_line_audio})
|
| 239 |
+
previous_end_time_ms = max(previous_end_time_ms, intended_start_time + current_audio_duration)
|
| 240 |
max_end_time_ms = max(max_end_time_ms, previous_end_time_ms)
|
| 241 |
elif audio_paths:
|
| 242 |
for path in audio_paths:
|
|
|
|
| 311 |
if __name__ == "__main__":
|
| 312 |
demo = asyncio.run(create_demo())
|
| 313 |
demo.launch()
|
|
|