Pengwei Li
commited on
Commit
•
8d99114
1
Parent(s):
3d50426
Update app.py
Browse files
app.py
CHANGED
@@ -3,76 +3,26 @@ os.system("pip install gradio==2.8.0b2")
|
|
3 |
import gradio as gr
|
4 |
import numpy as np
|
5 |
|
6 |
-
title = "
|
7 |
|
8 |
description = "Gradio Demo for fairseq S2S: speech-to-speech translation models. To use it, simply add your audio, or click one of the examples to load them. Read more at the links below."
|
9 |
|
10 |
-
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/
|
11 |
|
12 |
examples = [
|
13 |
-
["common_voice_es_en.flac","
|
14 |
-
["common_voice_ru_18945535.flac","xm_transformer_600m-ru_en-multi_domain"],
|
15 |
-
["common_voice_fr_19731305.mp3","xm_transformer_600m-fr_en-multi_domain"],
|
16 |
-
["common_voice_en_ru.mp3","xm_transformer_600m-en_ru-multi_domain"],
|
17 |
-
["common_voice_en_es.mp3","xm_transformer_600m-en_es-multi_domain"],
|
18 |
-
["common_voice_en_ar.mp3","xm_transformer_600m-en_ar-multi_domain"],
|
19 |
-
["common_voice_en_tr.mp3","xm_transformer_600m-en_tr-multi_domain"],
|
20 |
-
["common_voice_en_fr.mp3","xm_transformer_600m-en_fr-multi_domain"],
|
21 |
-
["common_voice_en_vi.mp3","xm_transformer_600m-en_vi-multi_domain"],
|
22 |
]
|
23 |
|
24 |
-
io1 = gr.Interface.load("huggingface/facebook/
|
25 |
-
|
26 |
-
io2 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-ru_en-multi_domain")
|
27 |
-
|
28 |
-
io3 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_ru-multi_domain")
|
29 |
-
|
30 |
-
io4 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_es-multi_domain")
|
31 |
-
|
32 |
-
io5 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_zh-multi_domain")
|
33 |
-
|
34 |
-
io6 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-fr_en-multi_domain")
|
35 |
-
|
36 |
-
io7 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_ar-multi_domain")
|
37 |
-
|
38 |
-
io8 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_tr-multi_domain")
|
39 |
-
|
40 |
-
io9 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_fr-multi_domain")
|
41 |
-
|
42 |
-
io10 = gr.Interface.load("huggingface/facebook/xm_transformer_600m-en_vi-multi_domain")
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
def inference(text,model):
|
50 |
-
|
51 |
-
outtext = io1(text)
|
52 |
-
elif model == "xm_transformer_600m-ru_en-multi_domain":
|
53 |
-
outtext = io2(text)
|
54 |
-
elif model == "xm_transformer_600m-en_ru-multi_domain":
|
55 |
-
outtext = io3(text)
|
56 |
-
elif model == "xm_transformer_600m-en_es-multi_domain":
|
57 |
-
outtext = io4(text)
|
58 |
-
elif model == "xm_transformer_600m-en_zh-multi_domain":
|
59 |
-
outtext = io5(text)
|
60 |
-
elif model == "xm_transformer_600m-fr_en-multi_domain":
|
61 |
-
outtext = io6(text)
|
62 |
-
elif model == "xm_transformer_600m-en_ar-multi_domain":
|
63 |
-
outtext = io7(text)
|
64 |
-
elif model == "xm_transformer_600m-en_tr-multi_domain":
|
65 |
-
outtext = io8(text)
|
66 |
-
elif model == "xm_transformer_600m-en_fr-multi_domain":
|
67 |
-
outtext = io9(text)
|
68 |
-
else:
|
69 |
-
outtext = io10(text)
|
70 |
return outtext
|
71 |
|
72 |
|
73 |
gr.Interface(
|
74 |
inference,
|
75 |
-
[gr.inputs.Audio(label="Input",type="filepath"),gr.inputs.Dropdown(choices=["
|
76 |
],
|
77 |
gr.outputs.Audio(label="Output"),
|
78 |
article=article,
|
|
|
3 |
import gradio as gr
|
4 |
import numpy as np
|
5 |
|
6 |
+
title = "Fairseq S2S"
|
7 |
|
8 |
description = "Gradio Demo for fairseq S2S: speech-to-speech translation models. To use it, simply add your audio, or click one of the examples to load them. Read more at the links below."
|
9 |
|
10 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2107.05604' target='_blank'>Direct speech-to-speech translation with discrete units</a> | <a href='https://github.com/facebookresearch/fairseq/tree/main/examples/speech_to_speech' target='_blank'>Github Repo</a></p>"
|
11 |
|
12 |
examples = [
|
13 |
+
["common_voice_es_en.flac","xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
]
|
15 |
|
16 |
+
io1 = gr.Interface.load("huggingface/facebook/xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022")
|
17 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def inference(text,model):
|
19 |
+
outtext = io1(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
return outtext
|
21 |
|
22 |
|
23 |
gr.Interface(
|
24 |
inference,
|
25 |
+
[gr.inputs.Audio(label="Input",type="filepath"),gr.inputs.Dropdown(choices=["xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"], type="value", default="xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022", label="model")
|
26 |
],
|
27 |
gr.outputs.Audio(label="Output"),
|
28 |
article=article,
|