lpw commited on
Commit
4c4b37d
1 Parent(s): 51263c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -11,23 +11,26 @@ description = "Gradio Demo for fairseq S2S: speech-to-speech translation models.
11
  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>"
12
 
13
  examples = [
14
- ["enhanced_direct_s2st_units_audios_es-en_set2_source_12478_cv.flac","xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"],
15
  ]
16
 
17
  io1 = gr.Interface.load("huggingface/facebook/xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022", api_key=st.secrets["api_key"])
18
 
19
- def inference(text,model):
20
- outtext = io1(text)
21
- return outtext
 
 
 
 
 
 
22
 
23
 
24
  gr.Interface(
25
- inference,
26
- inputs=[
27
- gr.Audio(source="microphone", type="filepath", optional=True, label="Input"),
28
- gr.Audio(source="upload", type="filepath", optional=True, label="Input"),
29
- gr.inputs.Dropdown(choices=["xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"], default="xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022", type="value", label="Model"),
30
- ],
31
  gr.outputs.Audio(label="Output"),
32
  article=article,
33
  title=title,
 
11
  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>"
12
 
13
  examples = [
14
+ [None,"enhanced_direct_s2st_units_audios_es-en_set2_source_12478_cv.flac","xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"],
15
  ]
16
 
17
  io1 = gr.Interface.load("huggingface/facebook/xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022", api_key=st.secrets["api_key"])
18
 
19
+ def inference(mic,file,model):
20
+ if mic is not None and file is None:
21
+ audio = mic
22
+ elif file is not None and mic is None:
23
+ audio = file
24
+ else:
25
+ return "ERROR: You must and may only select one method, it cannot be empty or select both methods at once."
26
+ out_audio = io1(audio)
27
+ return out_audio
28
 
29
 
30
  gr.Interface(
31
+ inference,
32
+ [gr.inputs.Audio(source="microphone", type="filepath", optional=True, label="Input"),gr.inputs.Audio(source="upload", type="filepath", optional=True, label="Input"),gr.inputs.Dropdown(choices=["xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"], type="value", label="model")
33
+ ],
 
 
 
34
  gr.outputs.Audio(label="Output"),
35
  article=article,
36
  title=title,