hivecorp commited on
Commit
3fd60fc
·
verified ·
1 Parent(s): c3b81d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
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
- # Add small silence at start and end for natural spacing
211
- silence = AudioSegment.silent(duration=50)
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 high quality settings for precise timing
396
- final_audio.export(
397
- audio_path,
398
- format="mp3",
399
- bitrate="320k",
400
- parameters=["-ar", "48000", "-ac", "2"]
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)