vonewman commited on
Commit
75f67b4
1 Parent(s): ca290b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
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)