File size: 534 Bytes
2f691bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from transformers import pipeline

# Load the translation pipeline
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")

def translate(text):
    result = translator(text)
    return result[0]['translation_text']

# Create the Gradio interface
iface = gr.Interface(
    fn=translate,
    inputs="text",
    outputs="text",
    title="Language Translator to English",
    description="Enter text in any language and get the translation in English."
)

# Launch the app
iface.launch(share=True)