import gradio as gr | |
from transformers import pipeline | |
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr") | |
def translate_sentence(input_text): | |
"""Get a sentence in french. | |
And return his translation in english | |
""" | |
for value in translator(input_text)[0].values: | |
return value | |
iface = gr.Interface(fn = translate_sentence, inputs = 'text', output = 'text', | |
title = "Traduction EN-FR", | |
description = "Un mini google translate avec HuggingFace") | |
iface.launch(inline = False) |