-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (50 loc) · 1.35 KB
/
index.js
File metadata and controls
57 lines (50 loc) · 1.35 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
52
53
54
55
56
57
/*
NOTES
- part of the web speech api
- if the serviceURI attribute is unset, the API will the browser's own speech recongnition service
*/
const recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.lang = 'en-US';
recognition.interimResults = true;
recognition.addEventListener('result', event => {
console.log(event.results);
output.value = '';
for (result of event.results) {
if (!result.isFinal) {
livefeed.value = result[0].transcript;
break;
} else {
output.value += result[0].transcript + '\n\n';
}
}
});
window.action.addEventListener('click', event => {
if (event.currentTarget.innerText === '✅') {
recognition.start();
event.currentTarget.innerText = '❎';
} else {
event.currentTarget.innerText = '✅';
recognition.stop();
}
});
// VoucherCodes.co.uk Search
const vcsearchRecognition = new webkitSpeechRecognition();
vcsearchRecognition.lang = 'en-US';
vcsearchRecognition.interimResults = true;
vcsearchRecognition.addEventListener('result', event => {
for (result of event.results) {
if (result.isFinal) {
window.open(
`https://www.vouchercodes.co.uk/search/?q=${result[0].transcript}`
);
break;
}
}
});
window.vc.addEventListener('mousedown', event => {
vcsearchRecognition.start();
});
window.vc.addEventListener('mouseup', event => {
vcsearchRecognition.stop();
});