File size: 1,038 Bytes
659981a
ec09ed1
f577737
659981a
ec09ed1
659981a
ec09ed1
 
0fbc2ce
ec09ed1
 
225c9d9
ec09ed1
 
0fbc2ce
ec09ed1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
from transformers import pipeline


st.title("Multilingual Translator Chatbot")

# Choose the translation model from Hugging Face
translation_model = st.selectbox("Select translation model", ["Helsinki-NLP/opus-mt-en-de", "Helsinki-NLP/opus-mt-en-fr"])

# Load the translation pipeline
translator = pipeline(task="translation", model=translation_model)

# User input for translation
user_input = st.text_area("Enter text for translation:", "")

if st.button("Translate"):
    if user_input:
        # Perform translation
        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."
)