GermanTTS / app.py
inOXcrm's picture
Update app.py
e171f13
raw
history blame
862 Bytes
import gradio as gr
# Load spectrogram generator
from nemo.collections.tts.models import FastPitchModel
spec_generator = FastPitchModel.restore_from("inOXcrm/German_multispeaker_FastPitch_nemo")
# Load Vocoder
from nemo.collections.tts.models import HifiGanModel
model = HifiGanModel.from_pretrained(model_name="tts_de_hui_hifigan_ft_fastpitch_multispeaker_5")
# Generate audio
def generate_audio(speaker_id, input_txt):
sr=44100
parsed = spec_generator.parse(input_txt)
spectrogram = spec_generator.generate_spectrogram(tokens=parsed, speaker=speaker_id)
audio = model.convert_spectrogram_to_audio(spec=spectrogram)
return (sr, audio)
gr.Interface(
generate_audio,
[
gr.Textbox(type="text", value=1, label="Speaker ID (0-5)")
gr.Textbox(type="text", value=1, label="Input Text"),
],
"audio",
).launch()