Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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": "
|
10 |
-
"German": "
|
11 |
-
"Spanish": "
|
12 |
-
"Chinese": "Helsinki-NLP/opus-mt-en-zh",
|
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 |
-
#
|
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
|