|
import streamlit as st |
|
from transformers import pipeline |
|
pip install -r requirements.txt |
|
|
|
|
|
st.title("Multilingual Translator Chatbot") |
|
|
|
|
|
translation_model = st.selectbox("Select translation model", ["Helsinki-NLP/opus-mt-en-de", "Helsinki-NLP/opus-mt-en-fr"]) |
|
|
|
|
|
translator = pipeline(task="translation", model=translation_model) |
|
|
|
|
|
user_input = st.text_area("Enter text for translation:", "") |
|
|
|
if st.button("Translate"): |
|
if user_input: |
|
|
|
translated_text = translator(user_input, max_length=500)[0]['translation_text'] |
|
st.success(f"Translated Text: {translated_text}") |
|
else: |
|
st.warning("Please enter text for translation.") |
|
|
|
st.markdown("---") |
|
|
|
st.subheader("About") |
|
st.write( |
|
"This is a simple Multilingual Translator chatbot that uses the Hugging Face Transformers library." |
|
) |
|
st.write( |
|
"Select a translation model from the dropdown, enter text, and click 'Translate' to see the translation." |
|
) |
|
|