forked from lexoyo/marcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (32 loc) · 974 Bytes
/
index.js
File metadata and controls
36 lines (32 loc) · 974 Bytes
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
const config = require('./package.json').marcel;
const Listener = require('./listener').Listener;
const listener = new Listener(config);
const Thinker = require('./thinker').Thinker;
const thinker = new Thinker(config);
const Modes = require('./thinker').Modes;
const Speaker = require('./speaker').Speaker;
const speaker = new Speaker(config);
function onHeard(phrase, next) {
if(phrase === '') {
next(thinker.state);
}
else {
thinker.think(phrase, function() {
switch(thinker.mode) {
case Modes.LISTEN:
listener.usePredefinedWords = false;
break;
case Modes.LISTEN_WITH_PREDEFINED_WORDS:
listener.usePredefinedWords = true;
break;
default:
console.error('thinker has a lisening mode =', thinker.mode)
}
listener.lang = thinker.state.lang.current;
next(thinker.state);
});
}
}
speaker.say("Marcel starting...", function() {
listener.start(onHeard);
});