We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c778fa5 commit 40295f2Copy full SHA for 40295f2
20 - Speech Detection/index-START.html
@@ -12,7 +12,28 @@
12
<script>
13
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
14
15
+ const recognition = new SpeechRecognition();
16
+ recognition.interimResults = true;
17
18
+ let p = document.createElement('p');
19
+ const words = document.querySelector('.words');
20
+ words.appendChild(p);
21
+
22
+ recognition.addEventListener('result', e => {
23
+ const transcript = Array.from(e.results)
24
+ .map(result => result[0])
25
+ .map(result => result.transcript).join('');
26
27
+ p.textContent = transcript;
28
+ if(e.results[0].isFinal) {
29
+ p = document.createElement('p');
30
31
+ }
32
+ })
33
34
+ recognition.addEventListener('end', recognition.start);
35
36
+ recognition.start();
37
</script>
38
39
0 commit comments