Falln87 commited on
Commit
a38d62a
·
verified ·
1 Parent(s): ca171f4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from transformers import pipeline
4
+
5
+ pipe = pipeline("translation", model="t5-base")
6
+
7
+ def translate(text):
8
+ return pipe(text)[0]["translation_text"] # type: ignore
9
+
10
+ with gr.Blocks() as demo:
11
+ with gr.Row():
12
+ with gr.Column():
13
+ spanish = gr.Textbox(label="Spanish")
14
+ translate_btn = gr.Button(value="Translate")
15
+ with gr.Column():
16
+ english = gr.Textbox(label="English")
17
+
18
+ translate_btn.click(translate, inputs=spanish, outputs=english, api_name="translate-to-english")
19
+ examples = gr.Examples(examples=["Que pene tan grande tienes.", "Estás tomando anticonceptivos, ¿verdad?"],
20
+ inputs=[spanish])
21
+
22
+ demo.launch()