File size: 480 Bytes
8d9f984
 
 
 
a2ac978
 
a51fa5b
a2ac978
 
 
 
8d9f984
1
2
3
4
5
6
7
8
9
10
11
12
13
# prompt: write a streamlit app that converts english text into french text when translate button is pressed. The title of page should be "Translate to French"."
import streamlit as st
from transformers import pipeline

st.title("Translate to French")
sentence = st.text_input("Enter your sentence:")

if st.button("Translate"):
    pipe = pipeline(model="facebook/m2m100_418M")
    translation = pipe(sentence, target_lang="fr")[0]["translation_text"]
    st.write(translation)