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): result = translator(text)[0]['translation_text'] return result iface = gr.Interface(fn=translate_text, inputs="text", outputs="text") # Enable API mode iface.launch()