Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -131,16 +131,16 @@ def trim_audio(intervals, input_file_path, output_file_path):
|
|
| 131 |
segment = audio[start_time*1000:end_time*1000]
|
| 132 |
output_file_path_i = f"{output_file_path}_{i}.wav"
|
| 133 |
|
| 134 |
-
if len(segment) <
|
| 135 |
-
# Calculate how many times to repeat the audio to make it at least
|
| 136 |
-
repeat_count = (
|
| 137 |
# Repeat the audio
|
| 138 |
longer_audio = segment * repeat_count
|
| 139 |
# Save the extended audio
|
| 140 |
-
print(f"Audio was less than
|
| 141 |
longer_audio.export(output_file_path_i, format='wav')
|
| 142 |
else:
|
| 143 |
-
print("Audio is already
|
| 144 |
segment.export(output_file_path_i, format='wav')
|
| 145 |
|
| 146 |
import re
|
|
|
|
| 131 |
segment = audio[start_time*1000:end_time*1000]
|
| 132 |
output_file_path_i = f"{output_file_path}_{i}.wav"
|
| 133 |
|
| 134 |
+
if len(segment) < 5000:
|
| 135 |
+
# Calculate how many times to repeat the audio to make it at least 5 seconds long
|
| 136 |
+
repeat_count = (5000 // len(segment)) + 2
|
| 137 |
# Repeat the audio
|
| 138 |
longer_audio = segment * repeat_count
|
| 139 |
# Save the extended audio
|
| 140 |
+
print(f"Audio was less than 5 seconds. Extended to {len(longer_audio)} milliseconds.")
|
| 141 |
longer_audio.export(output_file_path_i, format='wav')
|
| 142 |
else:
|
| 143 |
+
print("Audio is already 5 seconds or longer.")
|
| 144 |
segment.export(output_file_path_i, format='wav')
|
| 145 |
|
| 146 |
import re
|