Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import torch
|
2 |
import torchaudio
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
device="cpu"
|
6 |
bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_PHONE_LJSPEECH
|
@@ -36,15 +37,17 @@ def inference(text):
|
|
36 |
spec, _, _ = tacotron2.infer(processed, lengths)
|
37 |
|
38 |
plt.imshow(spec[0].cpu().detach())
|
|
|
|
|
39 |
|
40 |
with torch.no_grad():
|
41 |
waveforms = waveglow.infer(spec)
|
42 |
|
43 |
torchaudio.save("output_waveglow.wav", waveforms[0:1].cpu(), sample_rate=22050)
|
44 |
-
return "output_waveglow.wav",
|
45 |
|
46 |
title="TACOTRON 2"
|
47 |
description="Gradio demo for TACOTRON 2: The Tacotron 2 model for generating mel spectrograms from text. To use it, simply add you text or click on one of the examples to load them. Read more at the links below."
|
48 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1712.05884' target='_blank'>Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions</a> | <a href='https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/SpeechSynthesis/Tacotron2' target='_blank'>Github Repo</a></p>"
|
49 |
examples=[["life is like a box of chocolates"]]
|
50 |
-
gr.Interface(inference,"text",[gr.outputs.Audio(type="file"),gr.outputs.Image(type="
|
|
|
1 |
import torch
|
2 |
import torchaudio
|
3 |
import gradio as gr
|
4 |
+
import matplotlib as plt
|
5 |
|
6 |
device="cpu"
|
7 |
bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_PHONE_LJSPEECH
|
|
|
37 |
spec, _, _ = tacotron2.infer(processed, lengths)
|
38 |
|
39 |
plt.imshow(spec[0].cpu().detach())
|
40 |
+
plt.axis('off')
|
41 |
+
plt.savefig("test.png", bbox_inches='tight')
|
42 |
|
43 |
with torch.no_grad():
|
44 |
waveforms = waveglow.infer(spec)
|
45 |
|
46 |
torchaudio.save("output_waveglow.wav", waveforms[0:1].cpu(), sample_rate=22050)
|
47 |
+
return "output_waveglow.wav","test.png"
|
48 |
|
49 |
title="TACOTRON 2"
|
50 |
description="Gradio demo for TACOTRON 2: The Tacotron 2 model for generating mel spectrograms from text. To use it, simply add you text or click on one of the examples to load them. Read more at the links below."
|
51 |
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1712.05884' target='_blank'>Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions</a> | <a href='https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/SpeechSynthesis/Tacotron2' target='_blank'>Github Repo</a></p>"
|
52 |
examples=[["life is like a box of chocolates"]]
|
53 |
+
gr.Interface(inference,"text",[gr.outputs.Audio(type="file"),gr.outputs.Image(type="file",label="Spectrogram")],title=title,description=description,article=article,examples=examples).launch(enable_queue=True)
|