gmdnn commited on
Commit
d867b66
·
1 Parent(s): 8c9154a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -9,22 +9,23 @@ description = "Gradio Demo for SpeechMatrix. To use it, simply record your audio
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=model_choices, default="xm_transformer_sm_all-en",type="value", label="Model")
28
  ],
29
  gr.outputs.Audio(label="Output"),
30
  article=article,
 
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
+ SRC_LIST = ['cs', 'de', 'en', 'es', 'et', 'fi', 'fr', 'hr', 'hu', 'it', 'nl', 'pl', 'pt', 'ro', 'sk', 'sl']
13
+ TGT_LIST = ['en', 'fr', 'es']
14
+ MODEL_LIST = ['xm_transformer_sm_all-en']
15
+ for src in SRC_LIST:
16
+ for tgt in TGT_LIST:
17
+ MODEL_LIST.append(f"textless_sm_{src}_{tgt}")
18
+
19
  examples = []
20
 
21
+ io_dict = {model: gr.Interface.load(f"huggingface/facebook/{model}") for model in MODEL_LIST}
22
 
23
  def inference(audio, model):
24
+ out_audio = io_dict[model](audio)
25
  return out_audio
 
 
 
 
 
 
26
  gr.Interface(
27
  inference,
28
+ [gr.inputs.Audio(source="microphone", type="filepath", label="Input"),gr.inputs.Dropdown(choices=MODEL_LIST, default="xm_transformer_sm_all-en",type="value", label="Model")
29
  ],
30
  gr.outputs.Audio(label="Output"),
31
  article=article,