Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,8 @@ from gtts import gTTS
|
|
| 5 |
from io import BytesIO
|
| 6 |
|
| 7 |
# Title and Introduction
|
| 8 |
-
st.title("
|
| 9 |
-
st.write("
|
| 10 |
|
| 11 |
# Sidebar Options
|
| 12 |
st.sidebar.header("Choose an Operation")
|
|
@@ -32,14 +32,8 @@ if operation == "Translate Text":
|
|
| 32 |
|
| 33 |
if st.button("Translate"):
|
| 34 |
try:
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
elif target_language == "English":
|
| 38 |
-
translator = pipeline("translation_multi_to_en", model="Helsinki-NLP/opus-mt-mul-en")
|
| 39 |
-
else:
|
| 40 |
-
st.error("Direct translation between two non-English languages is not supported.")
|
| 41 |
-
st.stop()
|
| 42 |
-
|
| 43 |
translation = translator(text, max_length=400)[0]['translation_text']
|
| 44 |
st.write("### Translation:")
|
| 45 |
st.write(translation)
|
|
|
|
| 5 |
from io import BytesIO
|
| 6 |
|
| 7 |
# Title and Introduction
|
| 8 |
+
st.title("Multilingual Language Learning App")
|
| 9 |
+
st.write("Learn and practice languages with translation, grammar correction, and pronunciation!")
|
| 10 |
|
| 11 |
# Sidebar Options
|
| 12 |
st.sidebar.header("Choose an Operation")
|
|
|
|
| 32 |
|
| 33 |
if st.button("Translate"):
|
| 34 |
try:
|
| 35 |
+
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-{target}".format(
|
| 36 |
+
target=languages[target_language]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
translation = translator(text, max_length=400)[0]['translation_text']
|
| 38 |
st.write("### Translation:")
|
| 39 |
st.write(translation)
|