-
Notifications
You must be signed in to change notification settings - Fork 13
/
voicecontrol.js
71 lines (58 loc) · 1.59 KB
/
voicecontrol.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
64
65
66
67
68
69
70
71
'use strict';
/* Magic Mirror
* Module: voicecontrol
*
* By Alex Yakhnin
* MIT Licensed.
*/
Module.register("voicecontrol", {
// Default module config.
defaults: {
models: [
{
keyword: "Show Camera",
description: "Say 'Show Camera' to display camera",
file: "showCamera.pmdl",
message: "SHOW_CAMERA"
},
{
keyword: "Hide Camera",
description: "Say 'Hide Camera' to hide camera",
file: "hideCamera.pmdl",
message: "HIDE_CAMERA"
},
{
keyword: "Selfie",
description: "Say 'Selfie' when camera is visible",
file: "selfie.pmdl",
message: "SELFIE"
},
]
},
start: function() {
this.sendSocketNotification("CONNECT", this.config);
},
getStyles: function() {
return ['voicecontrol.css'];
},
socketNotificationReceived: function(notification, payload){
if (notification === "KEYWORD_SPOTTED"){
//Broadcast the message
this.sendNotification(payload.message, {type: "notification"});
}
},
getDom: function() {
var wrapper = document.createElement("div");
var header = document.createElement("header");
header.innerHTML = "Voice Commands";
wrapper.appendChild(header);
var models = this.config.models;
models.forEach(function(model) {
var command = document.createElement("div");
command.innerHTML = model.description;
command.className = "small dimmed top";
wrapper.appendChild(command);
}, this);
return wrapper;
}
});