transengtoch / app.py
lilsha's picture
Upload 2 files
b5b57b6
raw
history blame contribute delete
No virus
779 Bytes
import streamlit as st
from transformers import pipeline
# Create a translation pipeline
translator = pipeline("translation", model="lilsha/transentoch")
def main():
st.title("Translate English to Chinese")
with st.form("text_field"):
text = st.text_area('Enter text:')
clicked = st.form_submit_button("Translate")
if clicked:
# Translate the input text
translation = translator(text, src_lang="en", tgt_lang="ch")
# Display the translated text
if translation:
st.write("Translation :")
st.write(translation[0]["translation_text"])
else:
st.write("Translation failed. Please check your input.")
if __name__ == "__main__":
main()