Ahsan658 commited on
Commit
1f50290
1 Parent(s): cf265ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -1,15 +1,12 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Load the translation pipeline from Hugging Face
5
- translator = pipeline("translation_en_to_fr") # Default to French translation
6
-
7
  # Available languages and their corresponding models
8
  available_languages = {
9
- "French": "translation_en_to_fr",
10
- "German": "translation_en_to_de",
11
- "Spanish": "translation_en_to_es",
12
- "Chinese": "Helsinki-NLP/opus-mt-en-zh", # For Chinese, we use a specific model from Hugging Face
13
  "Japanese": "Helsinki-NLP/opus-mt-en-jap",
14
  "Russian": "Helsinki-NLP/opus-mt-en-ru",
15
  "Arabic": "Helsinki-NLP/opus-mt-en-ar",
@@ -24,7 +21,7 @@ text_to_translate = st.text_area("Enter text in English:", "")
24
  # Language selection
25
  target_language = st.selectbox("Select the target language:", list(available_languages.keys()))
26
 
27
- # Change the translation model based on the selected language
28
  translator = pipeline("translation", model=available_languages[target_language])
29
 
30
  # Translate button
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
 
 
4
  # Available languages and their corresponding models
5
  available_languages = {
6
+ "French": "Helsinki-NLP/opus-mt-en-fr",
7
+ "German": "Helsinki-NLP/opus-mt-en-de",
8
+ "Spanish": "Helsinki-NLP/opus-mt-en-es",
9
+ "Chinese": "Helsinki-NLP/opus-mt-en-zh",
10
  "Japanese": "Helsinki-NLP/opus-mt-en-jap",
11
  "Russian": "Helsinki-NLP/opus-mt-en-ru",
12
  "Arabic": "Helsinki-NLP/opus-mt-en-ar",
 
21
  # Language selection
22
  target_language = st.selectbox("Select the target language:", list(available_languages.keys()))
23
 
24
+ # Load the translation model based on the selected language
25
  translator = pipeline("translation", model=available_languages[target_language])
26
 
27
  # Translate button