junmou commited on
Commit
4ef56cb
1 Parent(s): 8070dd7

Create translation en-zh

Browse files
Files changed (1) hide show
  1. translation en-zh +9 -0
translation en-zh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as grad
3
+ mdl_name = "Helsinki-NLP/opus-mt-en-zh"
4
+ opus_translator = pipeline("translation", model=mdl_name)
5
+ def translate(text):
6
+ response = opus_translator(text)
7
+ return response
8
+ grad.Interface(translate, inputs=["text",], outputs="text").
9
+ launch()