import streamlit as st from transformers import pipeline import nltk nltk.download('punkt') from nltk.tokenize import sent_tokenize # Load pipeline for translation st.set_page_config(page_title="English to Vietnamese Translator", page_icon="🌐", layout="wide") st.title("🌐 English to Vietnamese Translator") model_checkpoint = "hHoai/hoaih" translator = pipeline("translation", model=model_checkpoint) # Create two columns for input and output col1, col2 = st.columns(2) # Add CSS for styling st.markdown(""" """, unsafe_allow_html=True) with col1: st.header("Input") input_text = st.text_area("Enter English text here maximum 2 line:", height=300, placeholder="Type your text here...") with col2: st.header("Output") if input_text: sentences = sent_tokenize(input_text) translation_text = "" for sentence in sentences: translation = translator(sentence) translation_text += translation[0]["translation_text"] + " " st.text_area("Translated text will appear here:", value=translation_text.strip(), height=300, disabled=True) else: st.text_area("Translated text will appear here:", value="", height=300, disabled=True) # Add footer st.markdown("""
Developed with ❤️ by [hHoai]