PsychoNay commited on
Commit
9ee0d9e
·
verified ·
1 Parent(s): 2440b7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,3 +1,25 @@
1
- import trackio
 
2
 
3
- trackio.show()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from deep_translator import GoogleTranslator
2
+ import gradio as gr
3
 
4
+ def translation(text):
5
+ if not text:
6
+ return ""
7
+ try:
8
+ translator = GoogleTranslator(source='auto', target='en')
9
+ result = translator.translate(text)
10
+ return result
11
+ except Exception as e:
12
+ return f"Translation error: {str(e)}"
13
+
14
+ with gr.Blocks(title='Translation') as app:
15
+ gr.Markdown("# Text Translation")
16
+ with gr.Row():
17
+ inp_text = gr.Textbox(label='Input Text', lines=3)
18
+ with gr.Row():
19
+ output = gr.Textbox(label='Output', lines=3)
20
+ with gr.Row():
21
+ translate_btn = gr.Button("Translate")
22
+
23
+ translate_btn.click(fn=translation, inputs=inp_text, outputs=output)
24
+
25
+ app.launch()