Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
documentHTML5='''
|
4 |
+
<!DOCTYPE html>
|
5 |
+
<html>
|
6 |
+
<head>
|
7 |
+
<title>Read It Aloud</title>
|
8 |
+
<script type="text/javascript">
|
9 |
+
function readAloud() {
|
10 |
+
const text = document.getElementById("textArea").value;
|
11 |
+
const speech = new SpeechSynthesisUtterance(text);
|
12 |
+
window.speechSynthesis.speak(speech);
|
13 |
+
}
|
14 |
+
</script>
|
15 |
+
</head>
|
16 |
+
<body>
|
17 |
+
<h1>π Read It Aloud</h1>
|
18 |
+
<textarea id="textArea" rows="50" cols="80">
|
19 |
+
|
20 |
+
This is a text passage that will be read aloud if Streamlit wrapping HTML5 wrapping browser based speech works correctly.
|
21 |
+
|
22 |
+
If all works this html can be nested into a variable and then put into session using streamlit and HTML5.
|
23 |
+
|
24 |
+
</textarea>
|
25 |
+
<br>
|
26 |
+
<button onclick="readAloud()">π Read Aloud</button>
|
27 |
+
</body>
|
28 |
+
</html>
|
29 |
+
'''
|
30 |
+
|
31 |
+
st.html(documentHTML5)
|