Upload 2 files
Browse files
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 |
-
|
| 21 |
-
|
|
|
|
| 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(
|