import gradio as gr import time import urllib.request from pathlib import Path import os import torch import scipy.io.wavfile from espnet2.bin.tts_inference import Text2Speech from espnet2.utils.types import str_or_none from parallel_wavegan.utils import download_pretrained_model gos_text2speech = Text2Speech.from_pretrained( model_tag="https://huggingface.co/ahnafsamin/FastSpeech2-gronings/resolve/main/tts_train_fastspeech2_raw_char_tacotron_train.loss.ave.zip", vocoder_tag="parallel_wavegan/ljspeech_parallel_wavegan.v3" ) def inference(text,lang): with torch.no_grad(): if lang == "gronings": wav = gos_text2speech(text)["wav"] scipy.io.wavfile.write("out.wav", gos_text2speech.fs , wav.view(-1).cpu().numpy()) return "out.wav", "out.wav" title = "GroTTS" examples = [ ['Ze gingen mit klas noar waddendiek, over en deur bragel lopen.', 'gronings'] ] gr.Interface( inference, [gr.inputs.Textbox(label="input text", lines=3), gr.inputs.Radio(choices=["gronings"], type="value", default="gronings", label="language")], [gr.outputs.Audio(type="file", label="Output"), gr.outputs.File()], title=title, examples=examples ).launch(enable_queue=True)