File size: 718 Bytes
10f29e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ff01acf
10f29e7
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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.")