Spaces:
Runtime error
Runtime error
Create translation en-zh
Browse files- 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()
|