Spaces:
Sleeping
Sleeping
Update modules/translator.py
Browse files- modules/translator.py +19 -9
modules/translator.py
CHANGED
@@ -35,12 +35,22 @@ def text_translator(input_text : str, language : str) -> str:
|
|
35 |
return output_text
|
36 |
|
37 |
# Interface
|
38 |
-
|
39 |
-
gr.
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
return output_text
|
36 |
|
37 |
# Interface
|
38 |
+
def translator_interface():
|
39 |
+
with gr.Blocks() as demo:
|
40 |
+
gr.HTML("<h1 align = 'center'> Text Translator </h1>")
|
41 |
+
gr.HTML("<h4 align = 'center'> Translate to any language </h4>")
|
42 |
+
|
43 |
+
with gr.Row():
|
44 |
+
input_text = gr.Textbox(label="Enter the text that you want to translate")
|
45 |
+
language = gr.Textbox(label="Enter the language that you want it to translate to", placeholder="Example: Hindi, French, Bengali, etc.")
|
46 |
+
|
47 |
+
generate_btn = gr.Button(value='Generate')
|
48 |
+
output_text = gr.Textbox(label="Translated text")
|
49 |
+
|
50 |
+
generate_btn.click(fn=text_translator, inputs=[input_text, language], outputs=output_text)
|
51 |
+
|
52 |
+
return demo
|
53 |
+
|
54 |
+
# สำหรับแสดง Interface ใน app.py
|
55 |
+
def get_translator_tab():
|
56 |
+
return translator_interface()
|