File size: 1,353 Bytes
cf5f5dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr

title = "FastSpeech2"

description = "Gradio Demo for fairseq S^2: A Scalable and Integrable Speech Synthesis Toolkit. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."

article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2109.06912' target='_blank'>fairseq S^2: A Scalable and Integrable Speech Synthesis Toolkit</a> | <a href='https://github.com/pytorch/fairseq/tree/main/examples/speech_synthesis' target='_blank'>Github Repo</a></p>"

examples = [
    ["Hello, this is a test run.","fastspeech2-en-200_speaker-cv4"]
]

io1 = gr.Interface.load("huggingface/facebook/fastspeech2-en-200_speaker-cv4")

io2 = gr.Interface.load("huggingface/facebook/fastspeech2-en-ljspeech")




def inference(text, model):
    if model == "fastspeech2-en-200_speaker-cv4":
        audio = io1(text)
    else:
        audio = io2(text)
    return audio   
    
gr.Interface(
    inference, 
    [gr.inputs.Textbox(label="Input", lines=10),gr.inputs.Dropdown(choices=["fastspeech2-en-200_speaker-cv4","fastspeech2-en-ljspeech"], type="value", default="prophetnet-large-uncased", label="model")
], 
    gr.outputs.Audio(label="Output"),
    examples=examples,
    article=article,
    title=title,
    description=description).launch(enable_queue=True, cache_examples=True)