File size: 518 Bytes
48e0a4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import streamlit as st

st.title("πŸ”Š Read It Aloud")

text = st.text_area("Type the text you want to be read aloud here.", "Hello, world!")

read_aloud_js = """
<button onclick="readAloud()">πŸ”Š Read Aloud</button>
<script type="text/javascript">
    function readAloud() {
        const text = document.getElementById("textArea").value;
        const speech = new SpeechSynthesisUtterance(text);
        window.speechSynthesis.speak(speech);
    }
</script>
"""

st.markdown(read_aloud_js, unsafe_allow_html=True)