Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
st.title("Multilingual Translator Chatbot")
|
| 6 |
|
| 7 |
# Choose the translation model from Hugging Face
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Load the translation pipeline
|
| 11 |
-
translator = pipeline(task="translation", model=
|
| 12 |
|
| 13 |
# User input for translation
|
| 14 |
user_input = st.text_area("Enter text for translation:", "")
|
|
@@ -30,3 +36,4 @@ st.write(
|
|
| 30 |
st.write(
|
| 31 |
"Select a translation model from the dropdown, enter text, and click 'Translate' to see the translation."
|
| 32 |
)
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
st.title("Multilingual Translator Chatbot")
|
| 5 |
|
| 6 |
# Choose the translation model from Hugging Face
|
| 7 |
+
translation_models = {
|
| 8 |
+
"English to German": "Helsinki-NLP/opus-mt-en-de",
|
| 9 |
+
"English to French": "Helsinki-NLP/opus-mt-en-fr",
|
| 10 |
+
"English to Urdu": "Helsinki-NLP/opus-mt-en-ur",
|
| 11 |
+
# Add more language pairs as needed
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
selected_translation = st.selectbox("Select translation model", list(translation_models.keys()))
|
| 15 |
|
| 16 |
# Load the translation pipeline
|
| 17 |
+
translator = pipeline(task="translation", model=translation_models[selected_translation])
|
| 18 |
|
| 19 |
# User input for translation
|
| 20 |
user_input = st.text_area("Enter text for translation:", "")
|
|
|
|
| 36 |
st.write(
|
| 37 |
"Select a translation model from the dropdown, enter text, and click 'Translate' to see the translation."
|
| 38 |
)
|
| 39 |
+
|