11#!/usr/bin/node
22const program = require ( 'commander' ) ;
3+ const path = require ( 'path' ) ;
34const Voicer = require ( './../apps/agi/index' ) ;
45
56program
89 . option ( '-t, --type [type]' , 'recognition service type, like google, yandex, witai' )
910 . option ( '-k, --key [key]' , 'recognition service auth key' )
1011 . option ( '-d, --path [path]' , 'path to peernames.json' )
11- . helpOption ( '-h, --help' , 'read more information' ) ;
12+ . option ( '-c, --config [config]' , 'path to config.js' )
13+ . helpOption ( '-h, --help' , 'read more information' )
1214
1315program . parse ( process . argv ) ;
1416
@@ -17,19 +19,27 @@ if (!program.port) {
1719 // program.help();
1820}
1921
20- let config = {
21- agi : {
22- port : program . port || 3000 ,
23- } ,
24- record : { directory : program . records || '/var/records' , type : 'wav' , duration : 3 } ,
25- recognize : {
26- directory : program . records || '/var/records' ,
27- type : program . type || 'witai' , // ['yandex', 'google', 'witai']
28- options : {
29- developer_key : program . key || '6SQV3DEGQWIXW3R2EDFUMPQCVGOEIBCR' ,
22+ let config ;
23+
24+ if ( program . config ) {
25+ if ( path . resolve ( program . config ) ) {
26+ config = require ( program . config ) ;
27+ }
28+ } else {
29+ config = {
30+ agi : {
31+ port : program . port || 3000 ,
32+ } ,
33+ record : { directory : program . records || '/var/records' , type : 'wav' , duration : 3 } ,
34+ recognize : {
35+ directory : program . records || '/var/records' ,
36+ type : program . type || 'witai' , // ['yandex', 'google', 'witai']
37+ options : {
38+ developer_key : program . key || '6SQV3DEGQWIXW3R2EDFUMPQCVGOEIBCR' ,
39+ } ,
3040 } ,
31- } ,
32- } ;
41+ } ;
42+ }
3343
3444// console.log('config', config);
3545const voicer = new Voicer ( config ) ;
0 commit comments