Spaces:
Runtime error
Runtime error
| from transformers import pipeline | |
| import gradio as gr | |
| # Load translation model: English to Hindi | |
| translator = pipeline("translation_en_to_hi", model="Helsinki-NLP/opus-mt-en-hi") | |
| def translate_text(text): | |
| result = translator(text)[0]['translation_text'] | |
| return result | |
| # Gradio UI | |
| interface = gr.Interface( | |
| fn=translate_text, | |
| inputs="text", | |
| outputs="text", | |
| title="English to Hindi Translator", | |
| description="Type in English and get the Hindi translation." | |
| ) | |
| interface.launch() | |