import streamlit as st from transformers import pipeline # Load the translation pipeline for English to Urdu translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur") # Streamlit UI st.title("English to Urdu Translator") # Text input for translation text_to_translate = st.text_area("Enter text in English:", "") # Translate button if st.button("Translate"): if text_to_translate: # Translate the text directly to Urdu translated_text = translator(text_to_translate) # Display the translated text st.subheader("Translated Text:") st.write(translated_text[0]['translation_text']) else: st.write("Please enter some text to translate.")