-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtom-index.html
53 lines (39 loc) · 1.21 KB
/
tom-index.html
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
52
53
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.lang = "en-US";
recognition.maxAlternatives = 1;
recognition.onstart = function(){
}
recognition.onend = function(){
}
recognition.onresult = function(event){
if(typeof(event.results) == "undefined") {
recognition.stop();
return;
}
for(var i = event.resultIndex; i < event.results.length; i++){
if(event.results[i].isFinal){
console.log("final reults: " + event.results[i][0].transcript);
}else{
console.log("interim results: " + event.results[i][0].transcript);
}
}
}
function startButton(event){
recognition.start();
start_img.src = "https://speechlogger.appspot.com/images/micslash2.png";
}
function stopButton(event){
recognition.stop();
}
</script>
<div onmousedown="startButton(event);" onmouseup="stopButton(event)"><img alt="Start" id="start_img" src="https://speechlogger.appspot.com/images/micoff2.png"></div>
</body>
</html>