Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Pipeline dịch EN -> VI | |
| translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-vi") | |
| def translate(text): | |
| if not text.strip(): | |
| return "Vui lòng nhập câu tiếng Anh." | |
| result = translator(text, max_length=400) | |
| return result[0]["translation_text"] | |
| demo = gr.Interface( | |
| fn=translate, | |
| inputs=gr.Textbox(lines=3, label="Nhập câu TIẾNG ANH"), | |
| outputs=gr.Textbox(lines=3, label="Kết quả TIẾNG VIỆT"), | |
| title="M33 - Demo dịch EN → VI trên Hugging Face Spaces", | |
| description="Ứng dụng web AI đơn giản dùng Gradio + Transformers.", | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |