Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize the translation pipeline | |
| translator = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en") | |
| # Function to perform translation | |
| def translate(text): | |
| result = translator(text) | |
| return result[0]['translation_text'] | |
| # Create Gradio interface | |
| iface = gr.Interface(fn=translate, | |
| inputs="text", | |
| outputs="text", | |
| title="Language Translator", | |
| description="Translate any language to English") | |
| if __name__ == "__main__": | |
| iface.launch() | |