-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhumix-conversation.js
69 lines (49 loc) · 1.48 KB
/
humix-conversation.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
var HumixSense = require('humix-sense');
var Conv = require('./index');
var fs = require('fs');
//var moduleConfig = require('./config.js');
var config = {
"moduleName" : "humix-conversation-module",
"commands" : ["tts"],
"events" : ["stt"],
"log" : {
file : 'humix-conversation-module.log',
fileLevel : 'info',
consoleLevel : 'debug'
}
};
var humix = new HumixSense(config);
var conversation;
var hsm;
var logger;
console.log('========= starting ===========');
humix.on('connection', function(humixSensorModule){
hsm = humixSensorModule;
logger = hsm.getLogger();
logger.info('access config');
var conf = hsm.getDefaultConfig();
if(!conf){
if(fs.existsSync('./config.js')){
logger.info('using local config file')
conf = require('./config.js');
}else{
logger.error('fail to load conversation config. Exit');
process.exit(1);
}
}
logger.info('loading config: '+ JSON.stringify(conf));
conversation = new Conv(conf, logger)
conversation.init();
logger.info('Communication with humix-sense is now ready.');
hsm.on("tts", function (data) {
logger.debug('received tts data:'+data);
// TODO : Check the type of data.
conversation.say(data);
})
conversation.on('msg', function(msg) {
logger.debug('about to publish:' + msg);
if(hsm){
hsm.event('stt', msg);
}
});
});