speech_matrix / app.py
gmdnn's picture
Create new file
8cb6e2d
raw
history blame
1.32 kB
import os
os.system("pip install gradio==3.3")
import gradio as gr
import numpy as np
title = "SpeechMatrix Speech-to-speech Translation"
description = "Gradio Demo for SpeechMatrix. To use it, simply record your audio, or click the example to load. Read more at the links below."
article = "<p style='text-align: center'><a href='ADD LINK' target='_blank'>SpeechMatrix</a> | <a href='https://github.com/facebookresearch/fairseq/tree/ust' target='_blank'>Github Repo</a></p>"
examples = []
io1 = gr.Interface.load("huggingface/facebook/xm_transformer_sm_all-en")
def inference(audio, model):
out_audio = io1(audio)
return out_audio
model_choices = ["xm_transformer_sm_all-en"]
for src in ['cs', 'de', 'en', 'es', 'et', 'fi', 'fr', 'hr', 'hu', 'it', 'nl', 'pl', 'pt', 'ro', 'sk', 'sl']:
for tgt in ['en', 'fr', 'de']:
if src != tgt:
model_choices.append(f"textless_sm_{src}_{tgt}")
gr.Interface(
inference,
[gr.inputs.Audio(source="microphone", type="filepath", label="Input"),gr.inputs.Dropdown(choices=["xm_transformer_sm_all-en"], default="xm_transformer_sm_all-en",type="value", label="Model")
],
gr.outputs.Audio(label="Output"),
article=article,
title=title,
examples=examples,
cache_examples=False,
description=description).queue().launch()