habulaj commited on
Commit
f1883e0
·
verified ·
1 Parent(s): 51ca5e0

Update srt_utils.py

Browse files
Files changed (1) hide show
  1. srt_utils.py +14 -2
srt_utils.py CHANGED
@@ -335,8 +335,20 @@ def process_audio_for_transcription(input_file: str) -> str:
335
 
336
  # "Retire qualquer música de fundo" -> Extremely hard without AI like Spleeter.
337
  # But aggressive vocal isolation via EQ helps.
 
 
 
338
 
339
- filters = "highpass=f=200,lowpass=f=3000,dynaudnorm=f=150:g=15"
 
 
 
 
 
 
 
 
 
340
 
341
  try:
342
  command = [
@@ -352,7 +364,7 @@ def process_audio_for_transcription(input_file: str) -> str:
352
  output_file
353
  ]
354
 
355
- print(f"🔊 Processando áudio com FFmpeg: {' '.join(command)}")
356
  subprocess.run(command, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
357
 
358
  if os.path.exists(output_file):
 
335
 
336
  # "Retire qualquer música de fundo" -> Extremely hard without AI like Spleeter.
337
  # But aggressive vocal isolation via EQ helps.
338
+ # To avoid hallucinations during silence, we need to MUTE silence, not remove it (which breaks sync).
339
+ # We use 'afftdn' (FFT Denoise) to aggressively reduce background noise/music floor.
340
+ # We can also use a 'compand' filter as a Noise Gate to silence anything below a threshold.
341
 
342
+ # Filter Chain Strategy:
343
+ # 1. Highpass (300Hz) - Cut bass/rumble/drums
344
+ # 2. Lowpass (3000Hz) - Cut sibilance/high-hats
345
+ # 3. AFFTDN - Spectral noise reduction (aggressive)
346
+ # 4. Dynaudnorm - Normalize volume of speech
347
+
348
+ # Check if we can use afftdn (assuming recent ffmpeg from previous output)
349
+ # If not, we might fail, but let's try.
350
+
351
+ filters = "highpass=f=300,lowpass=f=3000,afftdn=nr=30:nf=-25,dynaudnorm=f=150:g=15"
352
 
353
  try:
354
  command = [
 
364
  output_file
365
  ]
366
 
367
+ print(f"🔊 Processando áudio com FFmpeg (Noise Gate/Spectral Cleaning): {' '.join(command)}")
368
  subprocess.run(command, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
369
 
370
  if os.path.exists(output_file):