Built motion from commit ecdc8e66766c75b1b08288b0ea13eb12d42606b4. Version 3.0.0...
[motion-next.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index b953e2b..ec86485 100644 (file)
@@ -1 +1 @@
-const a1044_0x223b=['Authentication\x20failed.','lodash','Tilde\x20ASR\x20parse\x20error','info','send','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.','isObject','Error\x20Tilde\x20ASR\x20socket','message','stringify','update','hex','close','likelihood','final','data','terminate','open','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','result','moment','unix','Open\x20Tilde\x20ASR\x20socket','error','sha1','createReadStream','Success.','isNil','parse','Tilde\x20URI','Tilde\x20ASR\x20hypoteses','crypto','transcript','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','hypotheses','Close\x20Tilde\x20ASR\x20socket','digest','Not\x20available.\x20Max\x20load\x20limit\x20reached.','agi','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','exports'];(function(_0x3972ae,_0x223b18){const _0x450d24=function(_0x30f0c7){while(--_0x30f0c7){_0x3972ae['push'](_0x3972ae['shift']());}};_0x450d24(++_0x223b18);}(a1044_0x223b,0x1e9));const a1044_0x450d=function(_0x3972ae,_0x223b18){_0x3972ae=_0x3972ae-0x0;let _0x450d24=a1044_0x223b[_0x3972ae];return _0x450d24;};const _0x5377d7=a1044_0x450d;'use strict';const _=require(_0x5377d7('0x4')),fs=require('fs'),WebSocket=require('ws'),moment=require(_0x5377d7('0x17')),crypto=require(_0x5377d7('0x22')),logger=require('../../../../../../config/logger')(_0x5377d7('0x0'));module[_0x5377d7('0x2')]=function(_0x30f0c7,_0x29d999,_0x48e632,_0x354c89){return new Promise(function(_0x3c6949){const _0x14b4bf=a1044_0x450d;logger[_0x14b4bf('0x6')](_0x14b4bf('0x20'),_0x354c89||_0x14b4bf('0x15'));const _0x1cc594=new WebSocket(_0x354c89||_0x14b4bf('0x15'),{'perMessageDeflate':![]});let _0xf349c2='',_0x1e840c='0',_0x5159bd='1',_0x39bbf1='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x3a280b(_0x31b0d6){const _0x4acc21=_0x14b4bf,_0x448c6e=crypto['createHash'](_0x4acc21('0x1b'));return _0x448c6e[_0x4acc21('0xd')](_0x31b0d6),_0x448c6e[_0x4acc21('0x27')](_0x4acc21('0xe'));}function _0x12336b(){const _0x432b4c=_0x14b4bf;try{logger[_0x432b4c('0x6')](_0x432b4c('0x19'));const _0x3f1353=moment()[_0x432b4c('0x18')](),_0x4cdf13=_0x3a280b(_0x3f1353+_0x29d999+_0x48e632);_0x1cc594[_0x432b4c('0x7')](JSON['stringify']({'appID':_0x29d999,'timestamp':_0x3f1353,'appKey':_0x4cdf13}));const _0x4425fc=fs[_0x432b4c('0x1c')](_0x30f0c7);_0x4425fc['on'](_0x432b4c('0x12'),function(_0x38f46a){const _0x519ef9=_0x432b4c;_0x1cc594[_0x519ef9('0x7')](_0x38f46a);}),_0x4425fc['on']('close',function(){const _0x2ec01f=_0x432b4c;_0x1cc594[_0x2ec01f('0x7')]('EOS');});}catch(_0x39ca06){logger[_0x432b4c('0x1a')]('Tilde\x20ASR\x20send\x20error',JSON[_0x432b4c('0xc')](_0x39ca06)),_0x1cc594[_0x432b4c('0x13')]();}}function _0x281deb(_0x1c1de7){const _0x280fae=_0x14b4bf;try{if(_0x1c1de7){const _0x1d8ece=JSON[_0x280fae('0x1f')](_0x1c1de7);switch(_0x1d8ece['status']){case 0x0:_0x1d8ece[_0x280fae('0x16')]&&(_0x1d8ece[_0x280fae('0x16')][_0x280fae('0x11')]&&(logger[_0x280fae('0x6')](_0x280fae('0x21'),JSON[_0x280fae('0xc')](_0x1d8ece[_0x280fae('0x16')][_0x280fae('0x25')])),_0xf349c2=_0x1d8ece[_0x280fae('0x16')][_0x280fae('0x25')][0x0][_0x280fae('0x23')],_0x1e840c=_0x1d8ece[_0x280fae('0x16')][_0x280fae('0x25')][0x0][_0x280fae('0x10')],_0x5159bd='0',_0x39bbf1=_0x280fae('0x1d'),_0x1cc594[_0x280fae('0x13')]()));break;case 0x1:logger[_0x280fae('0x6')]('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech'),_0x5159bd='1',_0x39bbf1=_0x280fae('0x1');break;case 0x2:logger['info'](_0x280fae('0x8')),_0x5159bd='2',_0x39bbf1=_0x280fae('0x8');break;case 0x9:logger[_0x280fae('0x6')](_0x280fae('0x28')),_0x5159bd='9',_0x39bbf1=_0x280fae('0x28');break;case 0xa:logger[_0x280fae('0x6')](_0x280fae('0x3')),_0x5159bd='10',_0x39bbf1='Authentication\x20failed.';break;case 0xb:logger['info'](_0x280fae('0x24')),_0x5159bd='11',_0x39bbf1=_0x280fae('0x24');}}}catch(_0xbfbf65){logger[_0x280fae('0x1a')](_0x280fae('0x5'),JSON[_0x280fae('0xc')](_0xbfbf65)),_0x1cc594['terminate']();}}function _0x1e606b(){const _0x498e2d=_0x14b4bf;logger[_0x498e2d('0x6')](_0x498e2d('0x26')),_0x3c6949({'transcript':_0xf349c2,'confidence':_0x1e840c,'status':_0x5159bd,'status_message':_0x39bbf1});}function _0x51c416(_0x5de6bf){const _0x5e6d79=_0x14b4bf;logger['error'](_0x5e6d79('0xa')),!_[_0x5e6d79('0x1e')](_0x5de6bf)&&logger[_0x5e6d79('0x1a')](_[_0x5e6d79('0x9')](_0x5de6bf)?JSON[_0x5e6d79('0xc')](_0x5de6bf):_0x5de6bf);}_0x1cc594['on'](_0x14b4bf('0x14'),_0x12336b),_0x1cc594['on'](_0x14b4bf('0xb'),_0x281deb),_0x1cc594['on'](_0x14b4bf('0xf'),_0x1e606b),_0x1cc594['on'](_0x14b4bf('0x1a'),_0x51c416);});};
\ No newline at end of file
+const a1044_0x41c2=['Authentication\x20failed.','createReadStream','Error\x20Tilde\x20ASR\x20socket','sha1','exports','Close\x20Tilde\x20ASR\x20socket','hypotheses','send','hex','status','data','final','../../../../../../config/logger','update','error','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','crypto','message','lodash','stringify','digest','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.','unix','Open\x20Tilde\x20ASR\x20socket','open','likelihood','isObject','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','Success.','EOS','Tilde\x20ASR\x20parse\x20error','result','Not\x20available.\x20Max\x20load\x20limit\x20reached.','terminate','agi','transcript','close','info','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','parse','createHash'];(function(_0x44670c,_0x41c29b){const _0x37bc50=function(_0x55f4b8){while(--_0x55f4b8){_0x44670c['push'](_0x44670c['shift']());}};_0x37bc50(++_0x41c29b);}(a1044_0x41c2,0x189));const a1044_0x37bc=function(_0x44670c,_0x41c29b){_0x44670c=_0x44670c-0x0;let _0x37bc50=a1044_0x41c2[_0x44670c];return _0x37bc50;};const _0x400804=a1044_0x37bc;'use strict';const _=require(_0x400804('0x23')),fs=require('fs'),WebSocket=require('ws'),moment=require('moment'),crypto=require(_0x400804('0x21')),logger=require(_0x400804('0x1d'))(_0x400804('0xa'));module[_0x400804('0x15')]=function(_0x55f4b8,_0x80f93d,_0x4b4d70,_0x1974ff){return new Promise(function(_0x3d50ef){const _0x55eb1a=a1044_0x37bc;logger[_0x55eb1a('0xd')]('Tilde\x20URI',_0x1974ff||_0x55eb1a('0xe'));const _0x39bdb2=new WebSocket(_0x1974ff||_0x55eb1a('0xe'),{'perMessageDeflate':![]});let _0xf131ba='',_0x256312='0',_0x4825bc='1',_0xbeb1a2=_0x55eb1a('0x3');function _0x59386f(_0x5032b6){const _0x5472fb=_0x55eb1a,_0x3f2f36=crypto[_0x5472fb('0x10')](_0x5472fb('0x14'));return _0x3f2f36[_0x5472fb('0x1e')](_0x5032b6),_0x3f2f36[_0x5472fb('0x25')](_0x5472fb('0x19'));}function _0x16a3ae(){const _0x4f0f95=_0x55eb1a;try{logger[_0x4f0f95('0xd')](_0x4f0f95('0x28'));const _0x14a187=moment()[_0x4f0f95('0x27')](),_0x43bf7d=_0x59386f(_0x14a187+_0x80f93d+_0x4b4d70);_0x39bdb2[_0x4f0f95('0x18')](JSON['stringify']({'appID':_0x80f93d,'timestamp':_0x14a187,'appKey':_0x43bf7d}));const _0x3408d3=fs[_0x4f0f95('0x12')](_0x55f4b8);_0x3408d3['on'](_0x4f0f95('0x1b'),function(_0x1dde46){_0x39bdb2['send'](_0x1dde46);}),_0x3408d3['on'](_0x4f0f95('0xc'),function(){const _0x402814=_0x4f0f95;_0x39bdb2[_0x402814('0x18')](_0x402814('0x5'));});}catch(_0x3fa954){logger[_0x4f0f95('0x1f')]('Tilde\x20ASR\x20send\x20error',JSON['stringify'](_0x3fa954)),_0x39bdb2['terminate']();}}function _0x249947(_0x40caa4){const _0x26fe6f=_0x55eb1a;try{if(_0x40caa4){const _0x47c4dc=JSON[_0x26fe6f('0xf')](_0x40caa4);switch(_0x47c4dc[_0x26fe6f('0x1a')]){case 0x0:_0x47c4dc[_0x26fe6f('0x7')]&&(_0x47c4dc['result'][_0x26fe6f('0x1c')]&&(logger['info']('Tilde\x20ASR\x20hypoteses',JSON[_0x26fe6f('0x24')](_0x47c4dc[_0x26fe6f('0x7')][_0x26fe6f('0x17')])),_0xf131ba=_0x47c4dc[_0x26fe6f('0x7')][_0x26fe6f('0x17')][0x0][_0x26fe6f('0xb')],_0x256312=_0x47c4dc[_0x26fe6f('0x7')][_0x26fe6f('0x17')][0x0][_0x26fe6f('0x1')],_0x4825bc='0',_0xbeb1a2=_0x26fe6f('0x4'),_0x39bdb2[_0x26fe6f('0x9')]()));break;case 0x1:logger[_0x26fe6f('0xd')](_0x26fe6f('0x3')),_0x4825bc='1',_0xbeb1a2=_0x26fe6f('0x3');break;case 0x2:logger[_0x26fe6f('0xd')]('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.'),_0x4825bc='2',_0xbeb1a2=_0x26fe6f('0x26');break;case 0x9:logger[_0x26fe6f('0xd')](_0x26fe6f('0x8')),_0x4825bc='9',_0xbeb1a2='Not\x20available.\x20Max\x20load\x20limit\x20reached.';break;case 0xa:logger[_0x26fe6f('0xd')](_0x26fe6f('0x11')),_0x4825bc='10',_0xbeb1a2=_0x26fe6f('0x11');break;case 0xb:logger['info'](_0x26fe6f('0x20')),_0x4825bc='11',_0xbeb1a2=_0x26fe6f('0x20');}}}catch(_0x3a5ae4){logger[_0x26fe6f('0x1f')](_0x26fe6f('0x6'),JSON[_0x26fe6f('0x24')](_0x3a5ae4)),_0x39bdb2[_0x26fe6f('0x9')]();}}function _0x454d00(){const _0x6ffb39=_0x55eb1a;logger['info'](_0x6ffb39('0x16')),_0x3d50ef({'transcript':_0xf131ba,'confidence':_0x256312,'status':_0x4825bc,'status_message':_0xbeb1a2});}function _0x3c4be0(_0x538572){const _0x434270=_0x55eb1a;logger['error'](_0x434270('0x13')),!_['isNil'](_0x538572)&&logger[_0x434270('0x1f')](_[_0x434270('0x2')](_0x538572)?JSON[_0x434270('0x24')](_0x538572):_0x538572);}_0x39bdb2['on'](_0x55eb1a('0x0'),_0x16a3ae),_0x39bdb2['on'](_0x55eb1a('0x22'),_0x249947),_0x39bdb2['on'](_0x55eb1a('0xc'),_0x454d00),_0x39bdb2['on']('error',_0x3c4be0);});};
\ No newline at end of file