-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
63 lines (46 loc) · 1.37 KB
/
main.js
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
58
59
60
61
62
63
var SpeechRecognition = window.webkitSpeechRecognition;
var recognition = new SpeechRecognition();
var Textbox = document.getElementById("textbox");
function start() {
Textbox.innerHTML = "";
recognition.start();
}
recognition.onresult = function (event) {
console.log(event);
var Content = event.results[0][0].transcript;
document.getElementById("textbox").innerHTML = Content;
console.log(Content);
if (Content == "take my selfie") {
console.log("taking selfie --- ");
speak();
}
}
function speak() {
var synth = window.speechSynthesis;
speak_data = "Taking you Selfie in 5 seconds";
var utterThis = new SpeechSynthesisUtterance(speak_data);
synth.speak(utterThis);
Webcam.attach(camera);
setTimeout(function () {
take_snapshot();
save();
}, 5000);
}
camera = document.getElementById("camera");
Webcam.set({
width: 360,
height: 250,
image_format: 'jpeg',
jpeg_quality: 90
});
function take_snapshot() {
Webcam.snap(function (data_uri) {
document.getElementById("result").innerHTML = '<img id="selfie_image" src="' + data_uri + '"/>';
});
}
function save() {
link = document.getElementById("link");
image = document.getElementById("selfie_image").src;
link.href = image;
link.click();
}