1 | /** |
||
2 | * Node |
||
3 | * |
||
4 | * LICENSE: MIT |
||
5 | * |
||
6 | * @project node-red-contrib-say |
||
7 | * @package NodeRedNode |
||
8 | * @author André Lademann <[email protected]> |
||
9 | * @copyright Copyright (c) 2014 programmerq.eu (http://programmerq.eu) |
||
10 | * @license http://programmerq.eu/license |
||
11 | * @since 2014-11-27 - 08:53:21 AM |
||
12 | */ |
||
13 | module.exports = function (RED) { |
||
14 | 'use strict'; |
||
15 | |||
16 | var say = require('say'); |
||
17 | |||
18 | /** |
||
19 | * Say node |
||
20 | * |
||
21 | * @property {*} config Configuration object |
||
22 | * @return void |
||
23 | **/ |
||
24 | function SayNode(config) { |
||
25 | RED.nodes.createNode(this, config); |
||
26 | var node = this; |
||
27 | this.on('input', function (msg) { |
||
28 | say.speak( |
||
29 | this.name || msg.payload, |
||
30 | this.voice, |
||
31 | 1, |
||
32 | function(err) { |
||
33 | if (err) { |
||
34 | return node.error(err); |
||
35 | } |
||
36 | node.send(msg); |
||
0 ignored issues
–
show
Best Practice
introduced
by
![]() |
|||
37 | }); |
||
38 | }); |
||
39 | } |
||
40 | |||
41 | RED.nodes.registerType('say', SayNode); |
||
42 | }; |
||
43 |