Spaces:
Sleeping
Sleeping
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() |