Spaces:
Sleeping
Sleeping
Download app.py from rapeephat222/transalate: direct link, hf CLI and curl.
- Browser
- Download file 749 Bytes
-
https://huggingface.co/spaces/rapeephat222/transalate/resolve/main/app.py
- Command line
-
hf download hf://spaces/rapeephat222/transalate/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rapeephat222/transalate/resolve/main/app.py
749 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) | |
| app.launch() # Simplified launch |