kevinwang676 commited on
Commit
16ddf32
β€’
1 Parent(s): c09fd29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -18
app.py CHANGED
@@ -22,14 +22,6 @@ import numpy as np
22
  # from IPython.display import Audio
23
 
24
  import torch
25
- import torchaudio
26
- from speechbrain.pretrained import SpectralMaskEnhancement
27
-
28
- enhance_model = SpectralMaskEnhancement.from_hparams(
29
- source="speechbrain/metricgan-plus-voicebank",
30
- savedir="pretrained_models/metricgan-plus-voicebank",
31
- run_opts={"device":"cuda"},
32
- )
33
 
34
  from TTS.tts.utils.synthesis import synthesis
35
  from TTS.tts.utils.text.symbols import make_symbols, phonemes, symbols
@@ -171,15 +163,7 @@ def voice_conversion(ta, ra, da):
171
  # print("Reference Audio after decoder:")
172
  # IPython.display.display(Audio(ref_wav_voc, rate=ap.sample_rate))
173
 
174
- noisy = enhance_model.load_audio(
175
- ref_wav_voc
176
- ).unsqueeze(0)
177
-
178
- enhanced = enhance_model.enhance_batch(noisy, lengths=torch.tensor([1.]))
179
- torchaudio.save("enhanced.wav", enhanced.cpu(), 16000)
180
-
181
- return "enhanced.wav"
182
-
183
 
184
  def generate_text_to_speech(text_prompt, selected_speaker, text_temp, waveform_temp):
185
  audio_array = generate_audio(text_prompt, selected_speaker, text_temp, waveform_temp)
@@ -262,7 +246,7 @@ with gr.Blocks() as demo:
262
  )
263
  gr.Markdown(
264
  """
265
- ### πŸ˜„ - You may also apply [VoiceFixer](https://huggingface.co/spaces/Kevin676/VoiceFixer) to the generated audio in order to enhance the speech.
266
  ## 🌎 Foreign Language
267
  Bark supports various languages out-of-the-box and automatically determines language from input text. \
268
  When prompted with code-switched text, Bark will even attempt to employ the native accent for the respective languages in the same voice.
 
22
  # from IPython.display import Audio
23
 
24
  import torch
 
 
 
 
 
 
 
 
25
 
26
  from TTS.tts.utils.synthesis import synthesis
27
  from TTS.tts.utils.text.symbols import make_symbols, phonemes, symbols
 
163
  # print("Reference Audio after decoder:")
164
  # IPython.display.display(Audio(ref_wav_voc, rate=ap.sample_rate))
165
 
166
+ return (ap.sample_rate, ref_wav_voc)
 
 
 
 
 
 
 
 
167
 
168
  def generate_text_to_speech(text_prompt, selected_speaker, text_temp, waveform_temp):
169
  audio_array = generate_audio(text_prompt, selected_speaker, text_temp, waveform_temp)
 
246
  )
247
  gr.Markdown(
248
  """
249
+ ## πŸ˜„ - You may also apply [VoiceFixer](https://huggingface.co/spaces/Kevin676/VoiceFixer) to the generated audio in order to enhance the speech.
250
  ## 🌎 Foreign Language
251
  Bark supports various languages out-of-the-box and automatically determines language from input text. \
252
  When prompted with code-switched text, Bark will even attempt to employ the native accent for the respective languages in the same voice.