miya3333 commited on
Commit
cd05d2b
·
verified ·
1 Parent(s): 5c027d2

Upload 2 files

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  import torch
3
  from speechbrain.inference.TTS import Tacotron2
4
  from speechbrain.inference.vocoders import HIFIGAN
 
5
 
6
  # モデルのロード
7
  hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="tmpdir_vocoder")
@@ -17,8 +18,9 @@ def synthesize_speech(text):
17
  waveforms = hifi_gan.decode_batch(mel_output)
18
 
19
  # torch tensorをwavfileとして保存
20
- torch.save(waveforms, "speech.pt")
21
- return "speech.pt"
 
22
 
23
  # Gradioインターフェースの作成
24
  iface = gr.Interface(
 
2
  import torch
3
  from speechbrain.inference.TTS import Tacotron2
4
  from speechbrain.inference.vocoders import HIFIGAN
5
+ from scipy.io.wavfile import write
6
 
7
  # モデルのロード
8
  hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="tmpdir_vocoder")
 
18
  waveforms = hifi_gan.decode_batch(mel_output)
19
 
20
  # torch tensorをwavfileとして保存
21
+ # sampling rate を 22050に設定
22
+ write("speech.wav", rate=22050, data=waveforms.squeeze().cpu().numpy())
23
+ return "speech.wav"
24
 
25
  # Gradioインターフェースの作成
26
  iface = gr.Interface(