import os os.system("pip install gradio==3.3") import gradio as gr import numpy as np import streamlit as st title = "Fairseq Speech to Speech Translation" description = "Gradio Demo for fairseq S2S: speech-to-speech translation models. To use it, simply record your audio, or click the example to load. Read more at the links below." article = "
Direct speech-to-speech translation with discrete units | Github Repo
" examples = [ ["enhanced_direct_s2st_units_audios_es-en_set2_source_12478_cv.flac","xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022"], ] io1 = gr.Interface.load("huggingface/facebook/xm_transformer_s2ut_800m-es-en-st-asr-bt_h1_2022", api_key=st.secrets["api_key"]) def inference(audio, model): # if mic is not None and file is None: # audio = mic # elif file is not None and mic is None: # audio = file # else: # return "ERROR: You must and may only select one method, it cannot be empty or select both methods at once." out_audio = io1(audio) return out_audio gr.Interface( inference, [gr.inputs.Audio(source="microphone", type="filepath", label="Input"),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") ], gr.outputs.Audio(label="Output"), article=article, title=title, description=description).queue().launch()