gmdnn commited on
Commit
8cb6e2d
·
1 Parent(s): 2665a3f

Create new file

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip install gradio==3.3")
3
+ import gradio as gr
4
+ import numpy as np
5
+
6
+ title = "SpeechMatrix Speech-to-speech Translation"
7
+
8
+ description = "Gradio Demo for SpeechMatrix. To use it, simply record your audio, or click the example to load. Read more at the links below."
9
+
10
+ article = "<p style='text-align: center'><a href='ADD LINK' target='_blank'>SpeechMatrix</a> | <a href='https://github.com/facebookresearch/fairseq/tree/ust' target='_blank'>Github Repo</a></p>"
11
+
12
+ examples = []
13
+
14
+ io1 = gr.Interface.load("huggingface/facebook/xm_transformer_sm_all-en")
15
+
16
+ def inference(audio, model):
17
+ out_audio = io1(audio)
18
+ return out_audio
19
+
20
+ model_choices = ["xm_transformer_sm_all-en"]
21
+ for src in ['cs', 'de', 'en', 'es', 'et', 'fi', 'fr', 'hr', 'hu', 'it', 'nl', 'pl', 'pt', 'ro', 'sk', 'sl']:
22
+ for tgt in ['en', 'fr', 'de']:
23
+ if src != tgt:
24
+ model_choices.append(f"textless_sm_{src}_{tgt}")
25
+ gr.Interface(
26
+ inference,
27
+ [gr.inputs.Audio(source="microphone", type="filepath", label="Input"),gr.inputs.Dropdown(choices=["xm_transformer_sm_all-en"], default="xm_transformer_sm_all-en",type="value", label="Model")
28
+ ],
29
+ gr.outputs.Audio(label="Output"),
30
+ article=article,
31
+ title=title,
32
+ examples=examples,
33
+ cache_examples=False,
34
+ description=description).queue().launch()