forked from fewieden/MMM-TTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_helper.js
38 lines (34 loc) · 1.01 KB
/
node_helper.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
/* Magic Mirror
* Module: MMM-TTS
*
* By fewieden https://github.com/fewieden/MMM-TTS
*
* MIT Licensed.
*/
/* eslint-env node */
const NodeHelper = require("node_helper");
const { exec } = require("child_process");
module.exports = NodeHelper.create({
start() {
console.log(`Starting node helper for: ${this.name}`);
},
socketNotificationReceived(notification, payload) {
if (notification === "CONFIG") {
this.config = payload;
} else if (notification === "TTS") {
const modulePath = `modules/${this.name}/`;
const cmd =
`${modulePath}/nanotts.sh ` +
`"${payload}" ` +
`${this.config.lang} ` +
`${this.config.speed} ` +
`${this.config.pitch} `;
exec(cmd, (err, stdout, stderr) => {
if (err) {
console.error(err);
}
this.sendSocketNotification("HIDE", {});
});
}
}
});