Dochee commited on
Commit
073e9ab
1 Parent(s): 0326ee9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as grad
3
+
4
+ mdl_name = "Helsinki-NLP/opus-mt-en-fr"
5
+
6
+ opus_translator = pipeline("translation",
7
+ model=mdl_name)
8
+
9
+ def translate(text):
10
+
11
+ response = opus_translator(text)
12
+
13
+ return response
14
+
15
+ txt=grad.Textbox(lines=1,
16
+ label="English",
17
+ placeholder="EnglishText here")
18
+
19
+ out=grad.Textbox(lines=1,
20
+ label="French")
21
+
22
+ grad.Interface(translate,
23
+ inputs=txt,
24
+ outputs=out).launch()