-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeechrecognition.html
More file actions
37 lines (31 loc) · 1.03 KB
/
Copy pathspeechrecognition.html
File metadata and controls
37 lines (31 loc) · 1.03 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
<!DOCTYPE html>
<html>
<head>
<script>
function startRecognition(){
document.getElementById("tbResult").value = "Starting recognition...";
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = function(event) {
let results = [];
for (let r of event.results){
for (let a of r){
results.push(a.transcript);
}
}
document.getElementById("tbResult").value = results.join(" ");
}
recognition.start();
}
</script>
</head>
<body>
<p>
<button type="button" onclick="startRecognition()">Begin!</button>
</p>
<p>
<input type="text" id="tbResult"></textarea>
</p>
</body>
</html>