QuaidKhalid commited on
Commit
ff01acf
·
verified ·
1 Parent(s): b99318b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -13
app.py CHANGED
@@ -4,28 +4,16 @@ from transformers import pipeline
4
  # Load the translation pipeline for English to Urdu
5
  translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur")
6
 
7
- # Supported languages for translation (including Urdu)
8
- supported_languages = {
9
- "Urdu": "ur",
10
- # Add more languages if needed
11
- }
12
-
13
  # Streamlit UI
14
  st.title("English to Urdu Translator")
15
 
16
  # Text input for translation
17
  text_to_translate = st.text_area("Enter text in English:", "")
18
 
19
- # Language selection (for now only Urdu is included)
20
- selected_language = st.selectbox("Select target language:", list(supported_languages.keys()))
21
-
22
  # Translate button
23
  if st.button("Translate"):
24
  if text_to_translate:
25
- # Get the corresponding language code (not strictly necessary for one language)
26
- target_language_code = supported_languages[selected_language]
27
-
28
- # Translate the text
29
  translated_text = translator(text_to_translate)
30
 
31
  # Display the translated text
 
4
  # Load the translation pipeline for English to Urdu
5
  translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur")
6
 
 
 
 
 
 
 
7
  # Streamlit UI
8
  st.title("English to Urdu Translator")
9
 
10
  # Text input for translation
11
  text_to_translate = st.text_area("Enter text in English:", "")
12
 
 
 
 
13
  # Translate button
14
  if st.button("Translate"):
15
  if text_to_translate:
16
+ # Translate the text directly to Urdu
 
 
 
17
  translated_text = translator(text_to_translate)
18
 
19
  # Display the translated text