hey_chatty / app.py
isana25's picture
Create app.py
88047cf verified
raw
history blame contribute delete
545 Bytes
import gradio as gr
from transformers import pipeline
# Load the translation pipeline from Hugging Face
translator = pipeline("translation_en_to_ur", model="Helsinki-NLP/opus-mt-en-ur")
# Define the translation function
def translate(text):
translated = translator(text)
return translated[0]['translation_text']
# Create the Gradio interface
interface = gr.Interface(
fn=translate,
inputs=gr.Textbox(label="Enter text in English"),
outputs=gr.Textbox(label="Translated text in Urdu")
)
# Launch the app
interface.launch()