Spaces:
Runtime error
Runtime error
File size: 809 Bytes
cc50a9c 9510815 cc50a9c 9510815 |
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 |
import gradio as gr
from transformers import pipeline
def translate(text,src,dst):
model_name = f"Helsinki-NLP/opus-mt-{src}-{dst}"
pipe = pipeline("translation", model=model_name)
return pipe(text)[0]["translation_text"]
demo = gr.Interface(
translate,
[
gr.Textbox(label="Texte a traduire"),
gr.Radio(["fr", "en","de","ru"], label="Langue source",value="fr"),
gr.Radio(["fr", "en","de","ru"], label="Langue cible",value="en"),
],
"text",
examples=[
["Mon nom est Thomas et je vis à Paris.","fr","en"],
["My name is Bob and I live in London.","en","fr"],
["Mein Name ist Wolfgang und ich lebe in Berlin.","de","fr"],
["Меня зовут Сара и я живу в Лондоне.","ru","fr"],
]
)
demo.launch() |