TestApp / app.py
AlexVed's picture
Update app.py
b3036aa verified
raw
history blame contribute delete
531 Bytes
import streamlit as st
from transformers import pipeline
# Load the translation model
translator = pipeline('translation_en_to_uk', model='Helsinki-NLP/opus-mt-en-uk')
# Streamlit UI
st.title("English to Ukrainian Translator")
text = st.text_area("Enter English text:")
if st.button("Translate"):
if text:
translated_text = translator(text, max_length=100)[0]['translation_text']
st.subheader("Translation:")
st.write(translated_text)
else:
st.warning("Please enter text to translate.")