File size: 531 Bytes
b3036aa a02892b b3036aa f6f0134 a02892b b3036aa dc290f9 b3036aa dc290f9 b3036aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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.")
|