Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 1108efc..245cd65 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc82e=['bluebird','moment','crypto','../../../../../../config/logger','agi','exports','Tilde\x20URI','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','sha1','update','hex','info','Open\x20Tilde\x20ASR\x20socket','unix','send','stringify','createReadStream','data','close','EOS','error','Tilde\x20ASR\x20send\x20error','terminate','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','transcript','likelihood','Success.','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','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','isNil','isObject','open'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0xc82e,0xd2));var _0xec82=function(_0x334f64,_0x1e0b74){_0x334f64=_0x334f64-0x0;var _0x2de374=_0xc82e[_0x334f64];return _0x2de374;};'use strict';var BPromise=require(_0xec82('0x0'));var _=require('lodash');var fs=require('fs');var WebSocket=require('ws');var moment=require(_0xec82('0x1'));var crypto=require(_0xec82('0x2'));var logger=require(_0xec82('0x3'))(_0xec82('0x4'));module[_0xec82('0x5')]=function(_0x17bc5b,_0xd04e9b,_0x57527e,_0x4c371b){return new BPromise(function(_0x39e868,_0x3d393a){logger['info'](_0xec82('0x6'),_0x4c371b||_0xec82('0x7'));var _0x44498d=new WebSocket(_0x4c371b||_0xec82('0x7'),{'perMessageDeflate':![]});var _0x3e5f89='';var _0x5ef0e9='0';var _0x2b5feb='1';var _0x544241='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x201e95(_0x1735cf){var _0x5cbe96=crypto['createHash'](_0xec82('0x8'));_0x5cbe96[_0xec82('0x9')](_0x1735cf);return _0x5cbe96['digest'](_0xec82('0xa'));}function _0x13cfd6(){try{logger[_0xec82('0xb')](_0xec82('0xc'));var _0x467604=moment()[_0xec82('0xd')]();var _0x4156af=_0x201e95(_0x467604+_0xd04e9b+_0x57527e);_0x44498d[_0xec82('0xe')](JSON[_0xec82('0xf')]({'appID':_0xd04e9b,'timestamp':_0x467604,'appKey':_0x4156af}));var _0x98265e=fs[_0xec82('0x10')](_0x17bc5b);_0x98265e['on'](_0xec82('0x11'),function(_0x1b4ac8){_0x44498d[_0xec82('0xe')](_0x1b4ac8);});_0x98265e['on'](_0xec82('0x12'),function(){_0x44498d[_0xec82('0xe')](_0xec82('0x13'));});}catch(_0x289c1b){logger[_0xec82('0x14')](_0xec82('0x15'),JSON[_0xec82('0xf')](_0x289c1b));_0x44498d[_0xec82('0x16')]();}}function _0x5f32de(_0x3f5ff6){try{if(_0x3f5ff6){var _0xf7118c=JSON[_0xec82('0x17')](_0x3f5ff6);switch(_0xf7118c[_0xec82('0x18')]){case 0x0:if(_0xf7118c[_0xec82('0x19')]){if(_0xf7118c[_0xec82('0x19')][_0xec82('0x1a')]){logger['info'](_0xec82('0x1b'),JSON[_0xec82('0xf')](_0xf7118c[_0xec82('0x19')][_0xec82('0x1c')]));_0x3e5f89=_0xf7118c['result'][_0xec82('0x1c')][0x0][_0xec82('0x1d')];_0x5ef0e9=_0xf7118c['result'][_0xec82('0x1c')][0x0][_0xec82('0x1e')];_0x2b5feb='0';_0x544241=_0xec82('0x1f');_0x44498d[_0xec82('0x16')]();}}break;case 0x1:logger['info'](_0xec82('0x20'));_0x2b5feb='1';_0x544241=_0xec82('0x20');break;case 0x2:logger[_0xec82('0xb')](_0xec82('0x21'));_0x2b5feb='2';_0x544241=_0xec82('0x21');break;case 0x9:logger[_0xec82('0xb')](_0xec82('0x22'));_0x2b5feb='9';_0x544241=_0xec82('0x22');break;case 0xa:logger[_0xec82('0xb')](_0xec82('0x23'));_0x2b5feb='10';_0x544241=_0xec82('0x23');break;case 0xb:logger[_0xec82('0xb')](_0xec82('0x24'));_0x2b5feb='11';_0x544241='All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.';}}}catch(_0x3d99b4){logger[_0xec82('0x14')](_0xec82('0x25'),JSON[_0xec82('0xf')](_0x3d99b4));_0x44498d['terminate']();}}function _0x4f810f(){logger[_0xec82('0xb')](_0xec82('0x26'));_0x39e868({'transcript':_0x3e5f89,'confidence':_0x5ef0e9,'status':_0x2b5feb,'status_message':_0x544241});}function _0x49d761(_0x37fa47){logger['error']('Error\x20Tilde\x20ASR\x20socket');if(!_[_0xec82('0x27')](_0x37fa47)){logger[_0xec82('0x14')](_[_0xec82('0x28')](_0x37fa47)?JSON[_0xec82('0xf')](_0x37fa47):_0x37fa47);}}_0x44498d['on'](_0xec82('0x29'),_0x13cfd6);_0x44498d['on']('message',_0x5f32de);_0x44498d['on']('close',_0x4f810f);_0x44498d['on'](_0xec82('0x14'),_0x49d761);});};
\ No newline at end of file
+var _0xf633=['error','Tilde\x20ASR\x20send\x20error','terminate','parse','result','final','Tilde\x20ASR\x20hypoteses','stringify','hypotheses','likelihood','Success.','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','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','isObject','message','lodash','moment','../../../../../../config/logger','agi','exports','info','Tilde\x20URI','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','createHash','sha1','update','digest','unix','createReadStream','data','send','close','EOS'];(function(_0x2641f9,_0x26715f){var _0x585741=function(_0x2d1462){while(--_0x2d1462){_0x2641f9['push'](_0x2641f9['shift']());}};_0x585741(++_0x26715f);}(_0xf633,0x14d));var _0x3f63=function(_0x504dbb,_0x3b7737){_0x504dbb=_0x504dbb-0x0;var _0x3c4b19=_0xf633[_0x504dbb];return _0x3c4b19;};'use strict';var BPromise=require('bluebird');var _=require(_0x3f63('0x0'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x3f63('0x1'));var crypto=require('crypto');var logger=require(_0x3f63('0x2'))(_0x3f63('0x3'));module[_0x3f63('0x4')]=function(_0xeedee7,_0x9e71b9,_0x32d412,_0xb0d9e5){return new BPromise(function(_0x184435,_0x47643a){logger[_0x3f63('0x5')](_0x3f63('0x6'),_0xb0d9e5||_0x3f63('0x7'));var _0x50e7bc=new WebSocket(_0xb0d9e5||_0x3f63('0x7'),{'perMessageDeflate':![]});var _0x482bec='';var _0x5b304c='0';var _0x198fd3='1';var _0x56367b='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x4cdf5a(_0x597d6b){var _0x3c2584=crypto[_0x3f63('0x8')](_0x3f63('0x9'));_0x3c2584[_0x3f63('0xa')](_0x597d6b);return _0x3c2584[_0x3f63('0xb')]('hex');}function _0x2d7ba4(){try{logger[_0x3f63('0x5')]('Open\x20Tilde\x20ASR\x20socket');var _0x37b4a9=moment()[_0x3f63('0xc')]();var _0x2415f3=_0x4cdf5a(_0x37b4a9+_0x9e71b9+_0x32d412);_0x50e7bc['send'](JSON['stringify']({'appID':_0x9e71b9,'timestamp':_0x37b4a9,'appKey':_0x2415f3}));var _0x40b0d6=fs[_0x3f63('0xd')](_0xeedee7);_0x40b0d6['on'](_0x3f63('0xe'),function(_0x219210){_0x50e7bc[_0x3f63('0xf')](_0x219210);});_0x40b0d6['on'](_0x3f63('0x10'),function(){_0x50e7bc[_0x3f63('0xf')](_0x3f63('0x11'));});}catch(_0x5030ef){logger[_0x3f63('0x12')](_0x3f63('0x13'),JSON['stringify'](_0x5030ef));_0x50e7bc[_0x3f63('0x14')]();}}function _0x45eb55(_0x3c49e2){try{if(_0x3c49e2){var _0x3cc39f=JSON[_0x3f63('0x15')](_0x3c49e2);switch(_0x3cc39f['status']){case 0x0:if(_0x3cc39f[_0x3f63('0x16')]){if(_0x3cc39f[_0x3f63('0x16')][_0x3f63('0x17')]){logger[_0x3f63('0x5')](_0x3f63('0x18'),JSON[_0x3f63('0x19')](_0x3cc39f[_0x3f63('0x16')][_0x3f63('0x1a')]));_0x482bec=_0x3cc39f['result'][_0x3f63('0x1a')][0x0]['transcript'];_0x5b304c=_0x3cc39f[_0x3f63('0x16')][_0x3f63('0x1a')][0x0][_0x3f63('0x1b')];_0x198fd3='0';_0x56367b=_0x3f63('0x1c');_0x50e7bc['terminate']();}}break;case 0x1:logger['info'](_0x3f63('0x1d'));_0x198fd3='1';_0x56367b=_0x3f63('0x1d');break;case 0x2:logger['info']('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.');_0x198fd3='2';_0x56367b=_0x3f63('0x1e');break;case 0x9:logger[_0x3f63('0x5')](_0x3f63('0x1f'));_0x198fd3='9';_0x56367b=_0x3f63('0x1f');break;case 0xa:logger[_0x3f63('0x5')](_0x3f63('0x20'));_0x198fd3='10';_0x56367b=_0x3f63('0x20');break;case 0xb:logger['info']('All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.');_0x198fd3='11';_0x56367b=_0x3f63('0x21');}}}catch(_0x54d2d8){logger['error'](_0x3f63('0x22'),JSON['stringify'](_0x54d2d8));_0x50e7bc[_0x3f63('0x14')]();}}function _0xa5a929(){logger[_0x3f63('0x5')](_0x3f63('0x23'));_0x184435({'transcript':_0x482bec,'confidence':_0x5b304c,'status':_0x198fd3,'status_message':_0x56367b});}function _0x5cce4a(_0x409d87){logger['error'](_0x3f63('0x24'));if(!_['isNil'](_0x409d87)){logger[_0x3f63('0x12')](_[_0x3f63('0x25')](_0x409d87)?JSON[_0x3f63('0x19')](_0x409d87):_0x409d87);}}_0x50e7bc['on']('open',_0x2d7ba4);_0x50e7bc['on'](_0x3f63('0x26'),_0x45eb55);_0x50e7bc['on'](_0x3f63('0x10'),_0xa5a929);_0x50e7bc['on']('error',_0x5cce4a);});};
\ No newline at end of file