Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -207,8 +207,8 @@ async def process_segment_with_timing(segment: Segment, voice: str, rate: str, p
|
|
| 207 |
|
| 208 |
try:
|
| 209 |
segment.audio = AudioSegment.from_file(audio_file)
|
| 210 |
-
#
|
| 211 |
-
silence = AudioSegment.silent(duration=
|
| 212 |
segment.audio = silence + segment.audio + silence
|
| 213 |
segment.duration = len(segment.audio)
|
| 214 |
except Exception as e:
|
|
@@ -392,13 +392,18 @@ async def generate_accurate_srt(
|
|
| 392 |
srt_path, audio_path = file_manager.create_output_paths()
|
| 393 |
|
| 394 |
try:
|
| 395 |
-
# Export with
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
|
| 403 |
with open(srt_path, "w", encoding='utf-8') as f:
|
| 404 |
f.write(srt_content)
|
|
|
|
| 207 |
|
| 208 |
try:
|
| 209 |
segment.audio = AudioSegment.from_file(audio_file)
|
| 210 |
+
# Reduced silence to 30ms for more natural flow
|
| 211 |
+
silence = AudioSegment.silent(duration=30)
|
| 212 |
segment.audio = silence + segment.audio + silence
|
| 213 |
segment.duration = len(segment.audio)
|
| 214 |
except Exception as e:
|
|
|
|
| 392 |
srt_path, audio_path = file_manager.create_output_paths()
|
| 393 |
|
| 394 |
try:
|
| 395 |
+
# Export with optimized quality settings and compression
|
| 396 |
+
export_params = {
|
| 397 |
+
'format': 'mp3',
|
| 398 |
+
'bitrate': '192k', # Reduced from 320k but still high quality
|
| 399 |
+
'parameters': [
|
| 400 |
+
'-ar', '44100', # Standard sample rate
|
| 401 |
+
'-ac', '2', # Stereo
|
| 402 |
+
'-compression_level', '0', # Best compression
|
| 403 |
+
'-qscale:a', '2' # High quality VBR encoding
|
| 404 |
+
]
|
| 405 |
+
}
|
| 406 |
+
final_audio.export(audio_path, **export_params)
|
| 407 |
|
| 408 |
with open(srt_path, "w", encoding='utf-8') as f:
|
| 409 |
f.write(srt_content)
|