Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
translator = pipeline("translation_en_to_hi", model="Helsinki-NLP/opus-mt-en-hi") | |
def translate_text(text): | |
if not text.strip(): | |
return "β οΈ Please provide input text." | |
return translator(text, max_length=400)[0]["translation_text"] | |
iface = gr.Interface(fn=translate_text, inputs="text", outputs="text") | |
iface.queue() | |
iface.launch() | |