|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
translator = pipeline("translation_en_to_fr", model="dreyyyy/EN-FR", device=-1) |
|
|
|
|
|
st.title("Translation Service") |
|
st.subheader("Translate English to French") |
|
st.write("This app uses a Hugging Face model to translate English text into French.") |
|
|
|
|
|
input_text = st.text_area("Enter English Text:", placeholder="Type your text here...") |
|
|
|
|
|
if st.button("Translate"): |
|
if input_text.strip(): |
|
|
|
result = translator(input_text) |
|
translated_text = result[0]["translation_text"] |
|
|
|
|
|
st.subheader("Translation in French:") |
|
st.write(translated_text) |
|
else: |
|
st.warning("Please enter some text to translate.") |
|
|