Spaces:
Runtime error
Runtime error
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system("pip install gradio==3.3")
|
3 |
+
import gradio as gr
|
4 |
+
import numpy as np
|
5 |
+
import streamlit as st
|
6 |
+
|
7 |
+
title = "Fairseq Speech to Speech Translation"
|
8 |
+
|
9 |
+
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."
|
10 |
+
|
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(audio, 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", 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")
|
33 |
+
],
|
34 |
+
gr.outputs.Audio(label="Output"),
|
35 |
+
article=article,
|
36 |
+
title=title,
|
37 |
+
examples=examples,
|
38 |
+
description=description).queue().launch()
|