File size: 677 Bytes
61693da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# app.py
import gradio as gr
from transformers import pipeline

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

def translate_to_english(text):
    # Translate the input text to English
    translation = translator(text)[0]['translation_text']
    return translation

# Define the Gradio interface
iface = gr.Interface(
    fn=translate_to_english, 
    inputs="text", 
    outputs="text", 
    title="Language to English Translator",
    description="Type any text in any language, and this app will translate it to English."
)

# Launch the Gradio app
if __name__ == "__main__":
    iface.launch()