lpw commited on
Commit
4b64e87
1 Parent(s): dbdfc0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -3,8 +3,7 @@ os.system("pip install gradio==3.3")
3
  import gradio as gr
4
  import numpy as np
5
  import streamlit as st
6
-
7
- from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
8
 
9
  title = "SpeechMatrix Speech-to-speech Translation"
10
 
@@ -21,18 +20,14 @@ for src in SRC_LIST:
21
  MODEL_LIST.append(f"textless_sm_{src}_{tgt}")
22
 
23
  examples = []
24
- MODEL_LIST = ['textless_sm_es_en', 'textless_sm_es_fr', 'textless_sm_et_en']
25
- print(MODEL_LIST)
26
 
27
  # io_dict = {model: gr.Interface.load(f"huggingface/facebook/{model}", api_key=st.secrets["api_key"]) for model in MODEL_LIST}
28
- # io_dict = {model: gr.Interface.load(f"huggingface/facebook/{model}") for model in MODEL_LIST}
29
- io_dict = {model: load_model_ensemble_and_task_from_hf_hub(f"facebook/{model}")[0] for model in MODEL_LIST}
30
 
31
  def inference(audio, model):
32
- print(io_dict)
33
- print(io_dict[model])
34
- out_audio = io_dict[model](audio)
35
- return out_audio
36
  gr.Interface(
37
  inference,
38
  [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")
 
3
  import gradio as gr
4
  import numpy as np
5
  import streamlit as st
6
+ from audio_pipe import SpeechToSpeechPipeline
 
7
 
8
  title = "SpeechMatrix Speech-to-speech Translation"
9
 
 
20
  MODEL_LIST.append(f"textless_sm_{src}_{tgt}")
21
 
22
  examples = []
 
 
23
 
24
  # io_dict = {model: gr.Interface.load(f"huggingface/facebook/{model}", api_key=st.secrets["api_key"]) for model in MODEL_LIST}
25
+ pipe_dict = {model: SpeechToSpeechPipeline(f"facebook/{model}") for model in MODEL_LIST}
 
26
 
27
  def inference(audio, model):
28
+ out_audio = pipe_dict[model](audio).get_config()["value"]["name"]
29
+ return out_audio
30
+
 
31
  gr.Interface(
32
  inference,
33
  [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")