Spaces:
Runtime error
Runtime error
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() |