gorkemgoknar commited on
Commit
d0834d6
1 Parent(s): 00e2817

remove denoiser, apply trim silence and speech detect loudness

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -80,14 +80,17 @@ def predict(prompt, language, audio_file_pth, mic_file_path, use_mic,no_lang_aut
80
  # This is fast filtering not perfect
81
  #lowpass_highpass="lowpass=5000,highpass=200"
82
 
83
- fast_denoise="afftdn=nr=12:nf=-25"
 
84
  # better to remove silence in beginning and end for microphone
85
- trim_silence="areverse,atrim=start=0.2,silenceremove=start_periods=1:start_silence=0:start_threshold=0.02,areverse,atrim=start=0.2,silenceremove=start_periods=1:start_silence=0:start_threshold=0.02"
86
 
 
 
87
  out_filename = mic_file_path + str(uuid.uuid4()) + ".wav" #ffmpeg to know output format
88
 
89
  #we will use newer ffmpeg as that has afftn denoise filter
90
- shell_command = f"./ffmpeg -y -i {mic_file_path} -af {fast_denoise},{trim_silence},loudnorm {out_filename}".split(" ")
91
 
92
  command_result = subprocess.run([item for item in shell_command], capture_output=False,text=True, check=True)
93
  speaker_wav=out_filename
 
80
  # This is fast filtering not perfect
81
  #lowpass_highpass="lowpass=5000,highpass=200"
82
 
83
+ #fast_denoise="afftdn=nr=12:nf=-25"
84
+
85
  # better to remove silence in beginning and end for microphone
86
+ trim_silence="areverse,atrim=start=0.1,silenceremove=start_periods=1:start_silence=0:start_threshold=0.02,areverse,atrim=start=0.1,silenceremove=start_periods=1:start_silence=0:start_threshold=0.02"
87
 
88
+ speechnorm="e=6.25:r=0.00001:l=1,"
89
+
90
  out_filename = mic_file_path + str(uuid.uuid4()) + ".wav" #ffmpeg to know output format
91
 
92
  #we will use newer ffmpeg as that has afftn denoise filter
93
+ shell_command = f"./ffmpeg -y -i {mic_file_path} -af {trim_silence},{speechnorm} {out_filename}".split(" ")
94
 
95
  command_result = subprocess.run([item for item in shell_command], capture_output=False,text=True, check=True)
96
  speaker_wav=out_filename