Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Load spectrogram generator
|
4 |
+
from nemo.collections.tts.models import FastPitchModel
|
5 |
+
spec_generator = FastPitchModel.restore_from("inOXcrm/German_multispeaker_FastPitch_nemo")
|
6 |
|
7 |
+
# Load Vocoder
|
8 |
+
from nemo.collections.tts.models import HifiGanModel
|
9 |
+
model = HifiGanModel.from_pretrained(model_name="tts_de_hui_hifigan_ft_fastpitch_multispeaker_5")
|
10 |
+
|
11 |
+
# Generate audio
|
12 |
+
|
13 |
+
def generate_audio(speaker_id, input_txt):
|
14 |
+
sr=44100
|
15 |
+
parsed = spec_generator.parse(input_txt)
|
16 |
+
spectrogram = spec_generator.generate_spectrogram(tokens=parsed, speaker=speaker_id)
|
17 |
+
audio = model.convert_spectrogram_to_audio(spec=spectrogram)
|
18 |
+
return (sr, audio)
|
19 |
+
|
20 |
+
|
21 |
+
gr.Interface(
|
22 |
+
generate_audio,
|
23 |
+
[
|
24 |
+
gr.Textbox(type="text", value=1, label="Speaker ID (0-5)")
|
25 |
+
gr.Textbox(type="text", value=1, label="Input Text"),
|
26 |
+
],
|
27 |
+
"audio",
|
28 |
+
).launch()
|