akhaliq HF staff commited on
Commit
83cc343
1 Parent(s): 41b7775

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ title = "fairseq S^2: A Scalable and Integrable Speech Synthesis Toolkit"
4
+
5
+ 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."
6
+
7
+ 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>"
8
+
9
+ examples = [
10
+ ["Hello this is a test run","fastspeech2-en-200_speaker-cv4"],
11
+ ["Hello, this is a test run.","tts_transformer-en-200_speaker-cv4"],
12
+ ["Bonjour, ceci est un test.","tts_transformer-fr-cv7_css10"],
13
+ ["BЗдравствуйте, это пробный запуск.","tts_transformer-ru-cv7_css10"],
14
+ ["Merhaba, bu bir deneme çalışmasıdır.","tts_transformer-tr-cv7"],
15
+ ["Xin chào, đây là một cuộc chạy thử nghiệm.","tts_transformer-vi-cv7"],
16
+ ["مرحبًا ، هذا اختبار تشغيل.","tts_transformer-ar-cv7"],
17
+ ["Hola, esta es una prueba.","tts_transformer-es-css10"]
18
+ ]
19
+
20
+ io1 = gr.Interface.load("huggingface/facebook/fastspeech2-en-200_speaker-cv4")
21
+
22
+ io2 = gr.Interface.load("huggingface/facebook/tts_transformer-en-200_speaker-cv4")
23
+
24
+ io3 = gr.Interface.load("huggingface/facebook/tts_transformer-fr-cv7_css10")
25
+
26
+ io4 = gr.Interface.load("huggingface/facebook/tts_transformer-ru-cv7_css10")
27
+
28
+ io5 = gr.Interface.load("huggingface/facebook/tts_transformer-tr-cv7")
29
+
30
+ io6 = gr.Interface.load("huggingface/facebook/tts_transformer-vi-cv7")
31
+
32
+ io7 = gr.Interface.load("huggingface/facebook/tts_transformer-ar-cv7")
33
+
34
+ io8 = gr.Interface.load("huggingface/facebook/tts_transformer-es-css10")
35
+
36
+
37
+
38
+ def inference(text,model):
39
+ if model == "fastspeech2-en-200_speaker-cv4":
40
+ outtext = io1(text)
41
+ elif model == "tts_transformer-en-200_speaker-cv4":
42
+ outtext = io2(text)
43
+ elif model == "tts_transformer-fr-cv7_css10":
44
+ outtext = io3(text)
45
+ elif model == "tts_transformer-ru-cv7_css10":
46
+ outtext = io4(text)
47
+ elif model == "tts_transformer-tr-cv7":
48
+ outtext = io5(text)
49
+ elif model == "tts_transformer-vi-cv7":
50
+ outtext = io6(text)
51
+ elif model == "tts_transformer-ar-cv7":
52
+ outtext = io7(text)
53
+ else:
54
+ outtext = io8(text)
55
+ return outtext
56
+
57
+
58
+ gr.Interface(
59
+ inference,
60
+ [gr.inputs.Textbox(label="Input",lines=5),gr.inputs.Dropdown(choices=["fastspeech2-en-200_speaker-cv4","tts_transformer-en-200_speaker-cv4","tts_transformer-tr-cv7","tts_transformer-fr-cv7_css10","tts_transformer-ru-cv7_css10","tts_transformer-vi-cv7","tts_transformer-ar-cv7","tts_transformer-es-css10"], type="value", default="fastspeech2-en-200_speaker-cv4", label="model")
61
+ ],
62
+ gr.outputs.Audio(label="Output"),
63
+ examples=examples,
64
+ article=article,
65
+ title=title,
66
+ description=description,
67
+ enable_queue=True).launch()