Built motion from commit d9028345.|2.5.43
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 4012708..50f9731 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4c10=['Close\x20Tilde\x20ASR\x20socket','Error\x20Tilde\x20ASR\x20socket','isNil','open','bluebird','lodash','moment','crypto','../../../../../../config/logger','agi','exports','info','Tilde\x20URI','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','createHash','update','digest','hex','Open\x20Tilde\x20ASR\x20socket','unix','createReadStream','data','close','EOS','error','Tilde\x20ASR\x20send\x20error','stringify','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','transcript','likelihood','Success.','terminate','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.','Not\x20available.\x20Max\x20load\x20limit\x20reached.','Authentication\x20failed.','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','Tilde\x20ASR\x20parse\x20error'];(function(_0x543084,_0x4337f5){var _0x306a57=function(_0x2769ed){while(--_0x2769ed){_0x543084['push'](_0x543084['shift']());}};_0x306a57(++_0x4337f5);}(_0x4c10,0x187));var _0x04c1=function(_0x297937,_0x4a2dcd){_0x297937=_0x297937-0x0;var _0x52449e=_0x4c10[_0x297937];return _0x52449e;};'use strict';var BPromise=require(_0x04c1('0x0'));var _=require(_0x04c1('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x04c1('0x2'));var crypto=require(_0x04c1('0x3'));var logger=require(_0x04c1('0x4'))(_0x04c1('0x5'));module[_0x04c1('0x6')]=function(_0x3a7e47,_0x25e7e6,_0x5ba3a7,_0x266628){return new BPromise(function(_0x3b3d0e,_0x4e21fe){logger[_0x04c1('0x7')](_0x04c1('0x8'),_0x266628||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x39fa96=new WebSocket(_0x266628||_0x04c1('0x9'),{'perMessageDeflate':![]});var _0x2293dc='';var _0xa6c6cc='0';var _0x57170e='1';var _0x3ba546=_0x04c1('0xa');function _0x29e27f(_0x30940a){var _0x446e77=crypto[_0x04c1('0xb')]('sha1');_0x446e77[_0x04c1('0xc')](_0x30940a);return _0x446e77[_0x04c1('0xd')](_0x04c1('0xe'));}function _0x5d2fd0(){try{logger[_0x04c1('0x7')](_0x04c1('0xf'));var _0xabdb99=moment()[_0x04c1('0x10')]();var _0x528d68=_0x29e27f(_0xabdb99+_0x25e7e6+_0x5ba3a7);_0x39fa96['send'](JSON['stringify']({'appID':_0x25e7e6,'timestamp':_0xabdb99,'appKey':_0x528d68}));var _0x4eae60=fs[_0x04c1('0x11')](_0x3a7e47);_0x4eae60['on'](_0x04c1('0x12'),function(_0x46263a){_0x39fa96['send'](_0x46263a);});_0x4eae60['on'](_0x04c1('0x13'),function(){_0x39fa96['send'](_0x04c1('0x14'));});}catch(_0x361d9b){logger[_0x04c1('0x15')](_0x04c1('0x16'),JSON[_0x04c1('0x17')](_0x361d9b));_0x39fa96['terminate']();}}function _0x3335d5(_0x40cd1a){try{if(_0x40cd1a){var _0x4752d8=JSON[_0x04c1('0x18')](_0x40cd1a);switch(_0x4752d8[_0x04c1('0x19')]){case 0x0:if(_0x4752d8[_0x04c1('0x1a')]){if(_0x4752d8[_0x04c1('0x1a')][_0x04c1('0x1b')]){logger[_0x04c1('0x7')](_0x04c1('0x1c'),JSON[_0x04c1('0x17')](_0x4752d8[_0x04c1('0x1a')][_0x04c1('0x1d')]));_0x2293dc=_0x4752d8[_0x04c1('0x1a')]['hypotheses'][0x0][_0x04c1('0x1e')];_0xa6c6cc=_0x4752d8[_0x04c1('0x1a')][_0x04c1('0x1d')][0x0][_0x04c1('0x1f')];_0x57170e='0';_0x3ba546=_0x04c1('0x20');_0x39fa96[_0x04c1('0x21')]();}}break;case 0x1:logger['info']('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x57170e='1';_0x3ba546=_0x04c1('0xa');break;case 0x2:logger[_0x04c1('0x7')]('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.');_0x57170e='2';_0x3ba546=_0x04c1('0x22');break;case 0x9:logger[_0x04c1('0x7')](_0x04c1('0x23'));_0x57170e='9';_0x3ba546=_0x04c1('0x23');break;case 0xa:logger[_0x04c1('0x7')](_0x04c1('0x24'));_0x57170e='10';_0x3ba546=_0x04c1('0x24');break;case 0xb:logger[_0x04c1('0x7')]('All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.');_0x57170e='11';_0x3ba546=_0x04c1('0x25');}}}catch(_0x8b14fe){logger[_0x04c1('0x15')](_0x04c1('0x26'),JSON[_0x04c1('0x17')](_0x8b14fe));_0x39fa96['terminate']();}}function _0x4738a0(){logger['info'](_0x04c1('0x27'));_0x3b3d0e({'transcript':_0x2293dc,'confidence':_0xa6c6cc,'status':_0x57170e,'status_message':_0x3ba546});}function _0x473904(_0x38aa00){logger[_0x04c1('0x15')](_0x04c1('0x28'));if(!_[_0x04c1('0x29')](_0x38aa00)){logger[_0x04c1('0x15')](_['isObject'](_0x38aa00)?JSON['stringify'](_0x38aa00):_0x38aa00);}}_0x39fa96['on'](_0x04c1('0x2a'),_0x5d2fd0);_0x39fa96['on']('message',_0x3335d5);_0x39fa96['on']('close',_0x4738a0);_0x39fa96['on'](_0x04c1('0x15'),_0x473904);});};
\ No newline at end of file
+var _0x1ff9=['Open\x20Tilde\x20ASR\x20socket','send','stringify','createReadStream','data','close','EOS','error','Tilde\x20ASR\x20send\x20error','terminate','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','transcript','likelihood','Success.','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.','Not\x20available.\x20Max\x20load\x20limit\x20reached.','Authentication\x20failed.','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','Tilde\x20ASR\x20parse\x20error','Close\x20Tilde\x20ASR\x20socket','Error\x20Tilde\x20ASR\x20socket','isNil','isObject','open','message','bluebird','lodash','moment','crypto','../../../../../../config/logger','exports','info','Tilde\x20URI','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','createHash','sha1','update','digest','hex'];(function(_0x26a846,_0x56c44a){var _0x35f524=function(_0x32f199){while(--_0x32f199){_0x26a846['push'](_0x26a846['shift']());}};_0x35f524(++_0x56c44a);}(_0x1ff9,0x78));var _0x91ff=function(_0x20f4ab,_0x472de6){_0x20f4ab=_0x20f4ab-0x0;var _0x2a391d=_0x1ff9[_0x20f4ab];return _0x2a391d;};'use strict';var BPromise=require(_0x91ff('0x0'));var _=require(_0x91ff('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x91ff('0x2'));var crypto=require(_0x91ff('0x3'));var logger=require(_0x91ff('0x4'))('agi');module[_0x91ff('0x5')]=function(_0x382afb,_0x2313b9,_0x3f22da,_0x16eb45){return new BPromise(function(_0xb3262a,_0x25ced4){logger[_0x91ff('0x6')](_0x91ff('0x7'),_0x16eb45||_0x91ff('0x8'));var _0x20e060=new WebSocket(_0x16eb45||_0x91ff('0x8'),{'perMessageDeflate':![]});var _0x47d2cf='';var _0xdc7d31='0';var _0x51c240='1';var _0x1d4a2f=_0x91ff('0x9');function _0x34104b(_0x2ed6d1){var _0x1b19a3=crypto[_0x91ff('0xa')](_0x91ff('0xb'));_0x1b19a3[_0x91ff('0xc')](_0x2ed6d1);return _0x1b19a3[_0x91ff('0xd')](_0x91ff('0xe'));}function _0x37b246(){try{logger[_0x91ff('0x6')](_0x91ff('0xf'));var _0x49244a=moment()['unix']();var _0x37efa8=_0x34104b(_0x49244a+_0x2313b9+_0x3f22da);_0x20e060[_0x91ff('0x10')](JSON[_0x91ff('0x11')]({'appID':_0x2313b9,'timestamp':_0x49244a,'appKey':_0x37efa8}));var _0x5cd7c5=fs[_0x91ff('0x12')](_0x382afb);_0x5cd7c5['on'](_0x91ff('0x13'),function(_0x24e45c){_0x20e060[_0x91ff('0x10')](_0x24e45c);});_0x5cd7c5['on'](_0x91ff('0x14'),function(){_0x20e060[_0x91ff('0x10')](_0x91ff('0x15'));});}catch(_0x2c342b){logger[_0x91ff('0x16')](_0x91ff('0x17'),JSON[_0x91ff('0x11')](_0x2c342b));_0x20e060[_0x91ff('0x18')]();}}function _0x21ac36(_0x2f2208){try{if(_0x2f2208){var _0x1cc55e=JSON[_0x91ff('0x19')](_0x2f2208);switch(_0x1cc55e[_0x91ff('0x1a')]){case 0x0:if(_0x1cc55e['result']){if(_0x1cc55e[_0x91ff('0x1b')][_0x91ff('0x1c')]){logger['info'](_0x91ff('0x1d'),JSON[_0x91ff('0x11')](_0x1cc55e[_0x91ff('0x1b')][_0x91ff('0x1e')]));_0x47d2cf=_0x1cc55e[_0x91ff('0x1b')][_0x91ff('0x1e')][0x0][_0x91ff('0x1f')];_0xdc7d31=_0x1cc55e[_0x91ff('0x1b')]['hypotheses'][0x0][_0x91ff('0x20')];_0x51c240='0';_0x1d4a2f=_0x91ff('0x21');_0x20e060[_0x91ff('0x18')]();}}break;case 0x1:logger[_0x91ff('0x6')](_0x91ff('0x9'));_0x51c240='1';_0x1d4a2f=_0x91ff('0x9');break;case 0x2:logger[_0x91ff('0x6')]('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.');_0x51c240='2';_0x1d4a2f=_0x91ff('0x22');break;case 0x9:logger[_0x91ff('0x6')](_0x91ff('0x23'));_0x51c240='9';_0x1d4a2f=_0x91ff('0x23');break;case 0xa:logger[_0x91ff('0x6')](_0x91ff('0x24'));_0x51c240='10';_0x1d4a2f=_0x91ff('0x24');break;case 0xb:logger['info']('All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.');_0x51c240='11';_0x1d4a2f=_0x91ff('0x25');}}}catch(_0x281946){logger['error'](_0x91ff('0x26'),JSON['stringify'](_0x281946));_0x20e060[_0x91ff('0x18')]();}}function _0x164756(){logger[_0x91ff('0x6')](_0x91ff('0x27'));_0xb3262a({'transcript':_0x47d2cf,'confidence':_0xdc7d31,'status':_0x51c240,'status_message':_0x1d4a2f});}function _0x50cbe9(_0x27b283){logger['error'](_0x91ff('0x28'));if(!_[_0x91ff('0x29')](_0x27b283)){logger[_0x91ff('0x16')](_[_0x91ff('0x2a')](_0x27b283)?JSON[_0x91ff('0x11')](_0x27b283):_0x27b283);}}_0x20e060['on'](_0x91ff('0x2b'),_0x37b246);_0x20e060['on'](_0x91ff('0x2c'),_0x21ac36);_0x20e060['on'](_0x91ff('0x14'),_0x164756);_0x20e060['on']('error',_0x50cbe9);});};
\ No newline at end of file