forked from fewieden/MMM-TTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-NanoTTS.js
50 lines (44 loc) · 1.14 KB
/
MMM-NanoTTS.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
/* Magic Mirror
* Module: MMM-TTS
*
* By fewieden https://github.com/fewieden/MMM-TTS
*
* MIT Licensed.
*/
Module.register("MMM-NanoTTS", {
tts: "",
defaults: {
text: "MMM-NanoTTS",
lang: "en-US",
speed: 1,
pitch: 1,
debug: false
},
start() {
Log.info(`Starting module: ${this.name}`);
this.tts = this.config.text;
this.sendSocketNotification("CONFIG", this.config);
},
notificationReceived(notification, payload) {
if (notification === "MMM-NanoTTS") {
const text = payload.text;
this.sendSocketNotification("TTS", text);
this.tts = payload;
this.updateDom();
}
},
socketNotificationReceived(notification) {
if (notification === "HIDE") {
this.tts = this.config.text;
this.updateDom();
}
},
getDom() {
const wrapper = document.createElement("div");
if (this.config.debug === true) {
wrapper.classList.add("thin", "small", "bright");
wrapper.innerHTML = this.tts;
}
return wrapper;
}
});