habulaj commited on
Commit
4aa5e54
·
verified ·
1 Parent(s): f2b004b

Update srt_utils.py

Browse files
Files changed (1) hide show
  1. srt_utils.py +12 -2
srt_utils.py CHANGED
@@ -367,11 +367,21 @@ def process_audio_for_transcription(input_file: str) -> str:
367
 
368
  ffmpeg_cmd = shutil.which("ffmpeg")
369
  if ffmpeg_cmd:
370
- # Compress to mono mp3 16k
 
 
 
 
 
 
 
 
 
371
  cmd_convert = [
372
  ffmpeg_cmd, "-y",
373
  "-i", vocals_path,
374
  "-ac", "1", "-ar", "16000",
 
375
  "-c:a", "libmp3lame", "-q:a", "2",
376
  final_output
377
  ]
@@ -391,4 +401,4 @@ def process_audio_for_transcription(input_file: str) -> str:
391
  traceback.print_exc()
392
 
393
  print("⚠️ Retornando arquivo original (fallback)")
394
- return input_file
 
367
 
368
  ffmpeg_cmd = shutil.which("ffmpeg")
369
  if ffmpeg_cmd:
370
+ # Compress to mono mp3 16k with aggressive voice enhancement
371
+ # Filters include highpass, noise reduction, compression, EQ, and normalization
372
+ filter_chain = (
373
+ "highpass=f=100,"
374
+ "afftdn=nr=10:nf=-50:tn=1,"
375
+ "compand=attacks=0:points=-80/-90|-45/-25|-27/-9|0/-7:gain=5,"
376
+ "equalizer=f=3000:width_type=h:width=1000:g=5,"
377
+ "loudnorm"
378
+ )
379
+
380
  cmd_convert = [
381
  ffmpeg_cmd, "-y",
382
  "-i", vocals_path,
383
  "-ac", "1", "-ar", "16000",
384
+ "-af", filter_chain,
385
  "-c:a", "libmp3lame", "-q:a", "2",
386
  final_output
387
  ]
 
401
  traceback.print_exc()
402
 
403
  print("⚠️ Retornando arquivo original (fallback)")
404
+ return input_file