Staticaliza commited on
Commit
6cad840
·
verified ·
1 Parent(s): 546984b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -12,6 +12,8 @@ import os
12
  from huggingface_hub import hf_hub_download
13
  from transformers import AutoFeatureExtractor, WhisperModel
14
  from torch.nn.utils import parametrizations
 
 
15
  from modules.commons import build_model, load_checkpoint, recursive_munch
16
  from modules.campplus.DTDNN import CAMPPlus
17
  from modules.bigvgan import bigvgan
@@ -321,6 +323,16 @@ def voice_conversion(input, reference, steps, guidance, speed):
321
  print("[INFO] | Final audio normalized.")
322
 
323
  # Smoothen the audio to reduce distorted audio
 
 
 
 
 
 
 
 
 
 
324
 
325
  # Save the audio to a temporary WAV file
326
  print("[INFO] | Saving final audio to a temporary WAV file.")
 
12
  from huggingface_hub import hf_hub_download
13
  from transformers import AutoFeatureExtractor, WhisperModel
14
  from torch.nn.utils import parametrizations
15
+ from scipy.signal import butter, lfilter
16
+
17
  from modules.commons import build_model, load_checkpoint, recursive_munch
18
  from modules.campplus.DTDNN import CAMPPlus
19
  from modules.bigvgan import bigvgan
 
323
  print("[INFO] | Final audio normalized.")
324
 
325
  # Smoothen the audio to reduce distorted audio
326
+ def butter_lowpass_filter(data, cutoff=3000, fs=sr_current, order=6):
327
+
328
+ nyq = 0.5 * fs
329
+ normal_cutoff = cutoff / nyq
330
+ b, a = butter(order, normal_cutoff, btype='low', analog=False)
331
+ y = lfilter(b, a, data)
332
+ return y
333
+
334
+ final_audio = butter_lowpass_filter(final_audio)
335
+ print("[INFO] | Final audio smoothed with low-pass filter.")
336
 
337
  # Save the audio to a temporary WAV file
338
  print("[INFO] | Saving final audio to a temporary WAV file.")