Spaces:
Running
Running
File size: 754 Bytes
3ea0ef7 bee31eb 5bab865 3ea0ef7 5bab865 3ea0ef7 5bab865 3ea0ef7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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='Translated Text', lines=3)
with gr.Row():
translate_btn = gr.Button("Translate")
translate_btn.click(fn=translation, inputs=inp_text, outputs=output)
app.launch(enable_queue=True) |