Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456718 unmodified lines26272829303132333435363738394041424344import streamlit as stfrom transformers import pipelinest.title("Multilingual Translator Chatbot")# Choose the translation models from Hugging Facetranslation_models = {18 unmodified lines# User input for translationuser_input = st.text_area("Enter text for translation:", "")if st.button("Translate"):if user_input:# Perform translationtranslated_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."1234567818 unmodified lines2728293031323334353637383940414243444546474849505152535455import streamlit as stimport timefrom transformers import pipelinest.title("Enhanced Multilingual Translator Chatbot")# Choose the translation models from Hugging Facetranslation_models = {18 unmodified lines# User input for translationuser_input = st.text_area("Enter text for translation:", "")# Display loading indicatorif st.button("Translate"):with st.spinner("Translating..."):# Simulate translation delay for demonstrationtime.sleep(2)if user_input:# Perform translationtranslated_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.")# Clear button to reset input and resultif st.button("Clear"):user_input = ""st.success("Input cleared.")st.empty() # Clear previous results if anyst.markdown("---")st.subheader("About")st.write("This is an enhanced 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."
app.py+19-8