Spaces:
Sleeping
Sleeping
Create app.2.py
Browse files
app.2.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
st.title("π Read It Aloud")
|
4 |
+
|
5 |
+
text = st.text_area("Type the text you want to be read aloud here.", "Hello, world!")
|
6 |
+
|
7 |
+
read_aloud_js = """
|
8 |
+
<button onclick="readAloud()">π Read Aloud</button>
|
9 |
+
<script type="text/javascript">
|
10 |
+
function readAloud() {
|
11 |
+
const text = document.getElementById("textArea").value;
|
12 |
+
const speech = new SpeechSynthesisUtterance(text);
|
13 |
+
window.speechSynthesis.speak(speech);
|
14 |
+
}
|
15 |
+
</script>
|
16 |
+
"""
|
17 |
+
|
18 |
+
st.markdown(read_aloud_js, unsafe_allow_html=True)
|