Spaces:
Runtime error
Runtime error
Download app.py from Noobjay/tagalog-translator: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/Noobjay/tagalog-translator/resolve/main/app.py
- Command line
-
hf download hf://spaces/Noobjay/tagalog-translator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Noobjay/tagalog-translator/resolve/main/app.py
1.32 kB
| import gradio as gr | |
| from transformers import pipeline | |
| # Load Tagalog to English model | |
| translator = pipeline("translation", model="Helsinki-NLP/opus-mt-tl-en") | |
| # Translation function | |
| def translate_tl_en(text): | |
| result = translator(text)[0]['translation_text'] | |
| return result | |
| # App layout | |
| with gr.Blocks(css="body { background-color: white; }") as app: | |
| # Running marquee with black text | |
| gr.HTML(""" | |
| <marquee scrollamount="5" style="color: black; font-size: 18px; font-weight: bold; margin-bottom: 10px;"> | |
| π€ Tagalog to English Translator | Created by Niko Jay Sedan with help from AI | Powered by Hugging Face | Fast, Free & Online! | |
| </marquee> | |
| """) | |
| # Header and description | |
| gr.Markdown("## π Tagalog to English AI Translator") | |
| gr.Markdown("This free online tool translates Tagalog text to English using artificial intelligence. Built by **Niko Jay Sedan** with the help of **Hugging Face AI models**. No API key required.") | |
| # Input/Output fields | |
| textbox_input = gr.Textbox(lines=2, label="π Tagalog Text") | |
| textbox_output = gr.Textbox(label="β English Translation") | |
| # Button | |
| translate_btn = gr.Button("Translate Now") | |
| translate_btn.click(translate_tl_en, inputs=textbox_input, outputs=textbox_output) | |
| # Launch the app | |
| app.launch() | |