Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
language_translation_ckpt = f"Helsinki-NLP/opus-mt-nl-en"
|
5 |
+
translator = pipeline("translation", model=language_translation_ckpt)
|
6 |
+
|
7 |
+
|
8 |
+
def translate_nl_en(text):
|
9 |
+
translation = translator(text)
|
10 |
+
translation = translation[0]['translation_text']
|
11 |
+
return translation
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
nl_text = gr.Textbox(label="NL")
|
15 |
+
en_text = gr.Textbox(label="EN")
|
16 |
+
translate_button = gr.Button("Translate")
|
17 |
+
translate_button.click(translate_nl_en, inputs=nl_text, outputs=en_text, api_name=translate_nl_en)
|
18 |
+
|
19 |
+
demo.launch()
|