Spaces:
Sleeping
Sleeping
File size: 599 Bytes
a03a679 adad0ac |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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()
|