-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathabs.html
More file actions
50 lines (40 loc) · 1.27 KB
/
abs.html
File metadata and controls
50 lines (40 loc) · 1.27 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
<html>
<body>
<p id="text">Waiting to start</p>
<script>
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener('click', start);
const p = document.getElementById('text');
const wait = (time = 1) => new Promise((r) => setTimeout(r, time * 1000));
speechSynthesis.getVoices();
const speak = (str) => {
p.innerHTML = str;
const k = new SpeechSynthesisUtterance(str);
k.voice = speechSynthesis.getVoices().find(({name}) => name === 'Veena');
return window.speechSynthesis.speak(k);
};
const fiveSeconds = async () => {
for (let i = 5; i; i--) {
speak(i);
await wait();
}
};
async function start() {
document.removeEventListener('click', start);
const sets = 10;
speak('Starting In 10 seconds...');
await wait(5);
await fiveSeconds();
for (let i = 1; i <= sets; i++) {
speak('round ' + i);
await wait(15);
await fiveSeconds();
if (i === sets) continue;
await fiveSeconds();
}
speak('Congratulations!!!');
}
});
</script>
</body>
</html>