Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 0b79179..4234915 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbfce=['close','lodash','moment','crypto','../../../../../../config/logger','agi','exports','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','info','Open\x20Tilde\x20ASR\x20socket','unix','stringify','createReadStream','data','send','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','Error\x20Tilde\x20ASR\x20socket','isNil','isObject','open','message'];(function(_0x24fef1,_0x2596fc){var _0x1dec46=function(_0x60ded8){while(--_0x60ded8){_0x24fef1['push'](_0x24fef1['shift']());}};_0x1dec46(++_0x2596fc);}(_0xbfce,0x161));var _0xebfc=function(_0xb400ce,_0x51e8dc){_0xb400ce=_0xb400ce-0x0;var _0x50b4bc=_0xbfce[_0xb400ce];return _0x50b4bc;};'use strict';var BPromise=require('bluebird');var _=require(_0xebfc('0x0'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0xebfc('0x1'));var crypto=require(_0xebfc('0x2'));var logger=require(_0xebfc('0x3'))(_0xebfc('0x4'));module[_0xebfc('0x5')]=function(_0x5a5ee8,_0x97919b,_0x5bdb79,_0x52ee11){return new BPromise(function(_0xb6099e,_0x45e96d){logger['info'](_0xebfc('0x6'),_0x52ee11||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x1f8827=new WebSocket(_0x52ee11||_0xebfc('0x7'),{'perMessageDeflate':![]});var _0x384816='';var _0x5b39b8='0';var _0x581708='1';var _0x50ca03=_0xebfc('0x8');function _0x22bf43(_0x18cb21){var _0xac56d4=crypto[_0xebfc('0x9')](_0xebfc('0xa'));_0xac56d4[_0xebfc('0xb')](_0x18cb21);return _0xac56d4[_0xebfc('0xc')](_0xebfc('0xd'));}function _0x6251db(){try{logger[_0xebfc('0xe')](_0xebfc('0xf'));var _0x2dbf9f=moment()[_0xebfc('0x10')]();var _0x30a1ec=_0x22bf43(_0x2dbf9f+_0x97919b+_0x5bdb79);_0x1f8827['send'](JSON[_0xebfc('0x11')]({'appID':_0x97919b,'timestamp':_0x2dbf9f,'appKey':_0x30a1ec}));var _0x44d239=fs[_0xebfc('0x12')](_0x5a5ee8);_0x44d239['on'](_0xebfc('0x13'),function(_0x93a4d4){_0x1f8827[_0xebfc('0x14')](_0x93a4d4);});_0x44d239['on']('close',function(){_0x1f8827[_0xebfc('0x14')]('EOS');});}catch(_0xe8f4f){logger[_0xebfc('0x15')](_0xebfc('0x16'),JSON[_0xebfc('0x11')](_0xe8f4f));_0x1f8827[_0xebfc('0x17')]();}}function _0xe6410b(_0x493a61){try{if(_0x493a61){var _0x54f178=JSON[_0xebfc('0x18')](_0x493a61);switch(_0x54f178[_0xebfc('0x19')]){case 0x0:if(_0x54f178[_0xebfc('0x1a')]){if(_0x54f178[_0xebfc('0x1a')][_0xebfc('0x1b')]){logger[_0xebfc('0xe')](_0xebfc('0x1c'),JSON[_0xebfc('0x11')](_0x54f178['result'][_0xebfc('0x1d')]));_0x384816=_0x54f178[_0xebfc('0x1a')][_0xebfc('0x1d')][0x0][_0xebfc('0x1e')];_0x5b39b8=_0x54f178[_0xebfc('0x1a')][_0xebfc('0x1d')][0x0][_0xebfc('0x1f')];_0x581708='0';_0x50ca03=_0xebfc('0x20');_0x1f8827['terminate']();}}break;case 0x1:logger[_0xebfc('0xe')](_0xebfc('0x8'));_0x581708='1';_0x50ca03='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';break;case 0x2:logger[_0xebfc('0xe')](_0xebfc('0x21'));_0x581708='2';_0x50ca03='Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.';break;case 0x9:logger[_0xebfc('0xe')](_0xebfc('0x22'));_0x581708='9';_0x50ca03=_0xebfc('0x22');break;case 0xa:logger[_0xebfc('0xe')](_0xebfc('0x23'));_0x581708='10';_0x50ca03=_0xebfc('0x23');break;case 0xb:logger['info'](_0xebfc('0x24'));_0x581708='11';_0x50ca03=_0xebfc('0x24');}}}catch(_0xad4a08){logger[_0xebfc('0x15')](_0xebfc('0x25'),JSON[_0xebfc('0x11')](_0xad4a08));_0x1f8827['terminate']();}}function _0x422dcc(){logger[_0xebfc('0xe')]('Close\x20Tilde\x20ASR\x20socket');_0xb6099e({'transcript':_0x384816,'confidence':_0x5b39b8,'status':_0x581708,'status_message':_0x50ca03});}function _0x52bf3a(_0x355c58){logger[_0xebfc('0x15')](_0xebfc('0x26'));if(!_[_0xebfc('0x27')](_0x355c58)){logger['error'](_[_0xebfc('0x28')](_0x355c58)?JSON['stringify'](_0x355c58):_0x355c58);}}_0x1f8827['on'](_0xebfc('0x29'),_0x6251db);_0x1f8827['on'](_0xebfc('0x2a'),_0xe6410b);_0x1f8827['on'](_0xebfc('0x2b'),_0x422dcc);_0x1f8827['on'](_0xebfc('0x15'),_0x52bf3a);});};
\ No newline at end of file
+var _0x0292=['data','send','error','Tilde\x20ASR\x20send\x20error','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','transcript','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','Close\x20Tilde\x20ASR\x20socket','Error\x20Tilde\x20ASR\x20socket','isNil','isObject','open','message','close','bluebird','lodash','moment','../../../../../../config/logger','agi','exports','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','info','Open\x20Tilde\x20ASR\x20socket','unix','stringify','createReadStream'];(function(_0x409353,_0xe9f04d){var _0x4f4b59=function(_0x64b587){while(--_0x64b587){_0x409353['push'](_0x409353['shift']());}};_0x4f4b59(++_0xe9f04d);}(_0x0292,0xbc));var _0x2029=function(_0x8a7e38,_0x473a5d){_0x8a7e38=_0x8a7e38-0x0;var _0x228609=_0x0292[_0x8a7e38];return _0x228609;};'use strict';var BPromise=require(_0x2029('0x0'));var _=require(_0x2029('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x2029('0x2'));var crypto=require('crypto');var logger=require(_0x2029('0x3'))(_0x2029('0x4'));module[_0x2029('0x5')]=function(_0x1b61a4,_0x1db0ac,_0x4dad74,_0x1a8359){return new BPromise(function(_0x3f74d3,_0x1aeb01){logger['info'](_0x2029('0x6'),_0x1a8359||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x62257d=new WebSocket(_0x1a8359||_0x2029('0x7'),{'perMessageDeflate':![]});var _0x843202='';var _0x11795e='0';var _0x29b260='1';var _0x2ac3ef=_0x2029('0x8');function _0x407693(_0x4c0da2){var _0x595e99=crypto[_0x2029('0x9')]('sha1');_0x595e99[_0x2029('0xa')](_0x4c0da2);return _0x595e99[_0x2029('0xb')]('hex');}function _0x599c8a(){try{logger[_0x2029('0xc')](_0x2029('0xd'));var _0x55359c=moment()[_0x2029('0xe')]();var _0x268ee0=_0x407693(_0x55359c+_0x1db0ac+_0x4dad74);_0x62257d['send'](JSON[_0x2029('0xf')]({'appID':_0x1db0ac,'timestamp':_0x55359c,'appKey':_0x268ee0}));var _0xb45278=fs[_0x2029('0x10')](_0x1b61a4);_0xb45278['on'](_0x2029('0x11'),function(_0x1a0a52){_0x62257d[_0x2029('0x12')](_0x1a0a52);});_0xb45278['on']('close',function(){_0x62257d[_0x2029('0x12')]('EOS');});}catch(_0x283efd){logger[_0x2029('0x13')](_0x2029('0x14'),JSON[_0x2029('0xf')](_0x283efd));_0x62257d['terminate']();}}function _0x4b85bc(_0xc69f5){try{if(_0xc69f5){var _0x4d8265=JSON[_0x2029('0x15')](_0xc69f5);switch(_0x4d8265[_0x2029('0x16')]){case 0x0:if(_0x4d8265[_0x2029('0x17')]){if(_0x4d8265[_0x2029('0x17')][_0x2029('0x18')]){logger[_0x2029('0xc')](_0x2029('0x19'),JSON[_0x2029('0xf')](_0x4d8265[_0x2029('0x17')][_0x2029('0x1a')]));_0x843202=_0x4d8265[_0x2029('0x17')]['hypotheses'][0x0][_0x2029('0x1b')];_0x11795e=_0x4d8265['result'][_0x2029('0x1a')][0x0]['likelihood'];_0x29b260='0';_0x2ac3ef='Success.';_0x62257d[_0x2029('0x1c')]();}}break;case 0x1:logger['info'](_0x2029('0x8'));_0x29b260='1';_0x2ac3ef='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';break;case 0x2:logger['info'](_0x2029('0x1d'));_0x29b260='2';_0x2ac3ef=_0x2029('0x1d');break;case 0x9:logger[_0x2029('0xc')](_0x2029('0x1e'));_0x29b260='9';_0x2ac3ef='Not\x20available.\x20Max\x20load\x20limit\x20reached.';break;case 0xa:logger[_0x2029('0xc')](_0x2029('0x1f'));_0x29b260='10';_0x2ac3ef='Authentication\x20failed.';break;case 0xb:logger[_0x2029('0xc')](_0x2029('0x20'));_0x29b260='11';_0x2ac3ef=_0x2029('0x20');}}}catch(_0x18bb42){logger['error'](_0x2029('0x21'),JSON['stringify'](_0x18bb42));_0x62257d['terminate']();}}function _0x1d6d15(){logger['info'](_0x2029('0x22'));_0x3f74d3({'transcript':_0x843202,'confidence':_0x11795e,'status':_0x29b260,'status_message':_0x2ac3ef});}function _0x3063f7(_0x51411f){logger['error'](_0x2029('0x23'));if(!_[_0x2029('0x24')](_0x51411f)){logger[_0x2029('0x13')](_[_0x2029('0x25')](_0x51411f)?JSON['stringify'](_0x51411f):_0x51411f);}}_0x62257d['on'](_0x2029('0x26'),_0x599c8a);_0x62257d['on'](_0x2029('0x27'),_0x4b85bc);_0x62257d['on'](_0x2029('0x28'),_0x1d6d15);_0x62257d['on'](_0x2029('0x13'),_0x3063f7);});};
\ No newline at end of file