File size: 1,660 Bytes
9fd9429 f7a3b8e 9fd9429 3d50426 f7a3b8e e48fc3a f7a3b8e c5e7677 4c4b37d f7a3b8e 2634b87 f7a3b8e 4c4b37d c5e7677 4c4b37d f7a3b8e e4b4d7f f7a3b8e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import os
os.system("pip install gradio==3.3")
import gradio as gr
import numpy as np
import streamlit as st
title = "Fairseq S2S"
description = "Gradio Demo for fairseq S2S: speech-to-speech translation models. To use it, simply add your audio, or click one of the examples to load them. Read more at the links below."
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>"
examples = [
[None,"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="upload", type="filepath", optional=True, 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,
examples=examples,
description=description).queue().launch() |