kevinwang676 commited on
Commit
19a53ac
1 Parent(s): 7bdb07b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -12
app.py CHANGED
@@ -19,12 +19,6 @@ import gradio as gr
19
  from scipy.io import wavfile
20
  from scipy.io.wavfile import write
21
 
22
- from speechbrain.pretrained import SpectralMaskEnhancement
23
-
24
- enhance_model = SpectralMaskEnhancement.from_hparams(
25
- source="speechbrain/metricgan-plus-voicebank",
26
- savedir="pretrained_models/metricgan-plus-voicebank",
27
- )
28
 
29
  knn_vc = torch.hub.load('bshall/knn-vc', 'knn_vc', prematched=True, trust_repo=True, pretrained=True, device='cpu')
30
 
@@ -51,12 +45,7 @@ def voice_change(audio_in, audio_ref):
51
  matching_set = knn_vc.get_matching_set(["./audio_ref.wav"])
52
  out_wav = knn_vc.match(query_seq, matching_set, topk=4)
53
  torchaudio.save('output.wav', out_wav[None], 16000)
54
- noisy = enhance_model.load_audio(
55
- 'output.wav'
56
- ).unsqueeze(0)
57
- enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
58
- torchaudio.save('enhanced.wav', enhanced.cpu(), 16000)
59
- return 'enhanced.wav'
60
 
61
 
62
  def tts(text, model, voice, api_key):
 
19
  from scipy.io import wavfile
20
  from scipy.io.wavfile import write
21
 
 
 
 
 
 
 
22
 
23
  knn_vc = torch.hub.load('bshall/knn-vc', 'knn_vc', prematched=True, trust_repo=True, pretrained=True, device='cpu')
24
 
 
45
  matching_set = knn_vc.get_matching_set(["./audio_ref.wav"])
46
  out_wav = knn_vc.match(query_seq, matching_set, topk=4)
47
  torchaudio.save('output.wav', out_wav[None], 16000)
48
+ return 'output.wav'
 
 
 
 
 
49
 
50
 
51
  def tts(text, model, voice, api_key):