Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
|
6 |
+
|
7 |
+
def translate_sentence(input_text):
|
8 |
+
"""Get a sentence in french.
|
9 |
+
And return his translation in english
|
10 |
+
"""
|
11 |
+
for value in translator(input_text)[0].values:
|
12 |
+
return value
|
13 |
+
|
14 |
+
iface = gr.Interface(fn = translate_sentence, inputs = 'text', output = 'text',
|
15 |
+
title = "Traduction EN-FR",
|
16 |
+
description = "Un mini google translate avec HuggingFace")
|
17 |
+
iface.launch(inline = False)
|