antirek / voicer

AGI-server voice recognizer for #Asterisk
MIT License
95 stars 35 forks source link

stepRepeatOnError TypeError: Cannot read property 'toLowerCase' of undefined at Promise #26

Open salvedi opened 4 years ago

salvedi commented 4 years ago

Добрый день! voicer в связке с wit.ai . .. для настройки использовал эту статью https://voxlink.ru/kb/asterisk-configuration/golosovoj-nabor-v-asterisk-2/ До карантина все работало ... проблема где-то во время карантина возникла. Если правильно понимаю, voicer сравнивает, но не выдает ответ ... 2020-6-11 22:30:56 - [32minfo [39m: 0000001 stepLookup read file /etc/voicer/data/peernames.json parsed [ { name: '333', target: 'SIP/333', variants: [ 'админ', 'иван валерьевич' ] } ] 2020-6-11 22:30:56 - [32minfo [39m: 0000001 stepRepeatOnError TypeError: Cannot read property 'toLowerCase' of undefined at Promise (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:11:24) at new Promise () at FileSource.find (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:10:12) at fileReader.readFile.then.then.then (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:48:23) at Спасибо!

antirek commented 4 years ago

немного выше в логе должна быть строка с тем, что вернул wit.ai скорее всего он ничего не вернул, поэтому такая ошибка

в первую очередь я бы проверил валидность ключа wit.ai, а также в интерфейсе wit.ai распознаваемые варианты

salvedi commented 4 years ago

Извиняюсь, что сократил лог ... тут 2 попытки, файл peernames.json создавал заново, для теста двух попыток. в интерфейсе wit.ai, в логах, распознает верно две попытки https://prnt.sc/t09o0n agi server started on port 3000 with config { agi: { port: 3000 }, processing: { totalAttempts: 2, playGreeting: true, playBeepBeforeRecording: false }, asterisk: { sounds: { onErrorBeforeFinish: 'ostavaytes', onErrorBeforeRepeat: 'eseraz', greeting: 'beep' }, recognitionDialplanVars: { status: 'RECOGNITION_RESULT', target: 'RECOGNITION_TARGET' } }, record: { directory: '/tmp', type: 'wav', duration: 3 }, recognize: { directory: '/tmp', type: 'witai', options: { developer_key: 'тут вроде как валидный ключ' } }, lookup: { type: 'file', options: { dataFile: '/etc/voicer/data/peernames.json' } } } 2020-6-11 22:30:51 - info: 0000001 -- start processing 2020-6-11 22:30:51 - info: 0000001 variables {"agi_network":"yes","agi_request":"agi","agi_channel":"PJSIP/NeoGate_TA410_FXO_1-000000fe","agi_language":"ru","agi_type":"PJSIP","agi_uniqueid":"1591903841.1097","agi_version":"16.6.2","agi_callerid":"8916номер","agi_calleridname":"Иван Валерьевич","agi_callingpres":"0","agi_callingani2":"0","agi_callington":"0","agi_callingtns":"0","agi_dnid":"504","agi_rdnis":"unknown","agi_context":"my-voicer","agi_extension":"s","agi_priority":"1","agi_enhanced":"0.0","agi_accountcode":"","agi_threadid":"140276051379968","":""} 2020-6-11 22:30:51 - info: 0000001 stepSetFailedVars 2020-6-11 22:30:51 - info: 0000001 set RECOGNITION_RESULT=FAILED 2020-6-11 22:30:51 - info: 0000001 stepGreeting 2020-6-11 22:30:51 - info: 0000001 answer 2020-6-11 22:30:51 - info: 0000001 o 2020-6-11 22:30:51 - info: 0000001 stepRecord /tmp/2843df57-04e6-4717-82b4-f387a6eb77b3 2020-6-11 22:30:51 - info: 0000001 stepRecord start record 2020-6-11 22:30:54 - info: 0000001 stepRecord end record 2020-6-11 22:30:54 - info: 0000001 stepRecognize /tmp/2843df57-04e6-4717-82b4-f387a6eb77b3.wav 2020-6-11 22:30:54 - info: 0000001 file /tmp/2843df57-04e6-4717-82b4-f387a6eb77b3.wav options { developer_key: 'тут вроде как валидный ключ', file: '/tmp/2843df57-04e6-4717-82b4-f387a6eb77b3.wav' } res Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: PassThrough { _readableState: [Object], readable: true, domain: null, _events: [Object], _eventsCount: 3, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: true, _transformState: [Object] }, disturbed: false, error: null }, [Symbol(Response internals)]: { url: 'https://api.wit.ai/speech', status: 200, statusText: 'OK', headers: Headers { [Symbol(map)]: [Object] }, counter: 0 } } json { entities: {}, intents: [], text: 'админ', traits: {} } 2020-6-11 22:30:56 - info: 0000001 text , intents=[], text=админ, 2020-6-11 22:30:56 - info: 0000001 err Error: Parse: no result at Promise (/usr/lib/node_modules/voicer/apps/agi/recognize/witaiParser.js:12:16) at new Promise () at WitaiParser.parse (/usr/lib/node_modules/voicer/apps/agi/recognize/witaiParser.js:4:12) at asrRequest.load.then (/usr/lib/node_modules/voicer/apps/agi/recognize/recognizer.js:19:30) at at process._tickCallback (internal/process/next_tick.js:188:7) 2020-6-11 22:30:56 - info: 0000001 stepLookup read file /etc/voicer/data/peernames.json parsed [ { name: '333', target: 'SIP/333', variants: [ 'админ', 'иван валерьевич' ] } ] 2020-6-11 22:30:56 - info: 0000001 stepRepeatOnError TypeError: Cannot read property 'toLowerCase' of undefined at Promise (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:11:24) at new Promise () at FileSource.find (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:10:12) at fileReader.readFile.then.then.then (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:48:23) at 2020-6-11 22:30:58 - info: 0000001 --- fail, make next attempt --- current=2, total=2 2020-6-11 22:30:58 - info: 0000001 stepRecord /tmp/2843df57-04e6-4717-82b4-f387a6eb77b3 2020-6-11 22:30:58 - info: 0000001 stepRecord start record 2020-6-11 22:31:01 - info: 0000001 stepRecord end record 2020-6-11 22:31:01 - info: 0000001 stepRecognize /tmp/2843df57-04e6-4717-82b4-f387a6eb77b3.wav 2020-6-11 22:31:01 - info: 0000001 file /tmp/2843df57-04e6-4717-82b4-f387a6eb77b3.wav options { developer_key: 'тут вроде как валидный ключ'', file: '/tmp/2843df57-04e6-4717-82b4-f387a6eb77b3.wav' } res Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: PassThrough { _readableState: [Object], readable: true, domain: null, _events: [Object], _eventsCount: 3, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: true, _transformState: [Object] }, disturbed: false, error: null }, [Symbol(Response internals)]: { url: 'https://api.wit.ai/speech', status: 200, statusText: 'OK', headers: Headers { [Symbol(map)]: [Object] }, counter: 0 } } json { entities: {}, intents: [], text: 'иван валерьевич', traits: {} } 2020-6-11 22:31:03 - info: 0000001 text , intents=[], text=иван валерьевич, 2020-6-11 22:31:03 - info: 0000001 err Error: Parse: no result at Promise (/usr/lib/node_modules/voicer/apps/agi/recognize/witaiParser.js:12:16) at new Promise () at WitaiParser.parse (/usr/lib/node_modules/voicer/apps/agi/recognize/witaiParser.js:4:12) at asrRequest.load.then (/usr/lib/node_modules/voicer/apps/agi/recognize/recognizer.js:19:30) at at process._tickCallback (internal/process/next_tick.js:188:7) 2020-6-11 22:31:03 - info: 0000001 stepLookup read file /etc/voicer/data/peernames.json parsed [ { name: '333', target: 'SIP/333', variants: [ 'админ', 'иван валерьевич' ] } ] 2020-6-11 22:31:03 - info: 0000001 stepError TypeError: Cannot read property 'toLowerCase' of undefined at Promise (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:11:24) at new Promise () at FileSource.find (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:10:12) at fileReader.readFile.then.then.then (/usr/lib/node_modules/voicer/apps/agi/source/fileSource.js:48:23) at 2020-6-11 22:31:06 - info: 0000001 stepFinish 2020-6-11 22:31:06 - info: 0000001 -- hangup 2020-6-11 22:31:06 - info: 0000001 stepFinish 2020-6-11 22:31:06 - info: 0000001 -- close

salvedi commented 4 years ago

npm install voicer -g `npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated node-uuid@1.4.8: Use uuid module instead /usr/bin/voicer -> /usr/lib/node_modules/voicer/bin/agi.js npm WARN notsup Unsupported engine for mkdirp@1.0.4: wanted: {"node":">=10"} (current: {"node":"8.11.3","npm":"6.14.5"}) npm WARN notsup Not compatible with your version of node/npm: mkdirp@1.0.4

все равно ошибка осталась ... не так обновляется, да?

ps Вручную исправил, спасибо, все работает!