-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
51 lines (40 loc) · 1.17 KB
/
index.html
File metadata and controls
51 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="file" id="inputfile" onchange="read()"><br><br>
<label><input type="checkbox" id="loop" onchange="toggleLoop();"> Loop</label><br><br>
<button onclick="speechSynthesis.pause();">Pause</button> <button onclick="speechSynthesis.resume();">Resume</button> <button onclick="stop(); speechSynthesis.cancel()">Stop</button>
<script>
var loop = false, msg;
msg = new SpeechSynthesisUtterance();
function toggleLoop() {
loop = loop == false ? true : false;
}
function stop() {
loop = false;
}
function read() {
var fr = new FileReader();
fr.readAsText(document.getElementById('inputfile').files[0]);
fr.onload = function () {
msg.lang = "hi";
msg.text = fr.result;
// msg.rate = 0.8;
window.speechSynthesis.speak(msg);
msg.onend = function () {
if (loop) {
console.log('hi');
read();
}
}
}
}
</script>
</body>
</html>