Sa-m's picture
Update app.py
11e03d8 verified
raw
history blame
784 Bytes
from deep_translator import GoogleTranslator
import gradio as gr
def translation(text):
if not text:
return ""
try:
translator = GoogleTranslator(source='auto', target='en')
result = translator.translate(text)
return result
except Exception as e:
return f"Translation error: {str(e)}"
with gr.Blocks(title='Translation') as app:
gr.Markdown("# Text Translation")
with gr.Row():
inp_text = gr.Textbox(label='Input Text', lines=3)
with gr.Row():
output = gr.Textbox(label='Output', lines=3)
with gr.Row():
translate_btn = gr.Button("Translate")
translate_btn.click(fn=translation, inputs=inp_text, outputs=output)
# Use queue=True instead of enable_queue=True
app.launch(queue=True)