Built motion from commit da617fac.|2.6.6
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 121ce8b..33ef209 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb0d8=['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','error','isObject','open','bluebird','lodash','moment','crypto','../../../../../../config/logger','agi','exports','info','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','sha1','update','digest','hex','Open\x20Tilde\x20ASR\x20socket','send','createReadStream','data','close','EOS','stringify','terminate','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','likelihood','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.'];(function(_0x187ee1,_0x3fd1e6){var _0x388160=function(_0x542dd2){while(--_0x542dd2){_0x187ee1['push'](_0x187ee1['shift']());}};_0x388160(++_0x3fd1e6);}(_0xb0d8,0x168));var _0x8b0d=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0xb0d8[_0x40a045];return _0x1a687c;};'use strict';var BPromise=require(_0x8b0d('0x0'));var _=require(_0x8b0d('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x8b0d('0x2'));var crypto=require(_0x8b0d('0x3'));var logger=require(_0x8b0d('0x4'))(_0x8b0d('0x5'));module[_0x8b0d('0x6')]=function(_0x31496c,_0x5da93c,_0x28ad5a,_0x370bda){return new BPromise(function(_0x1aad51,_0x122dca){logger[_0x8b0d('0x7')]('Tilde\x20URI',_0x370bda||_0x8b0d('0x8'));var _0x495ce4=new WebSocket(_0x370bda||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE',{'perMessageDeflate':![]});var _0xd46dfa='';var _0x5944be='0';var _0x7ebc4a='1';var _0x5cba0a='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x4ada24(_0x218cfd){var _0x9d6109=crypto['createHash'](_0x8b0d('0x9'));_0x9d6109[_0x8b0d('0xa')](_0x218cfd);return _0x9d6109[_0x8b0d('0xb')](_0x8b0d('0xc'));}function _0x756f3b(){try{logger[_0x8b0d('0x7')](_0x8b0d('0xd'));var _0x167eda=moment()['unix']();var _0x34ace9=_0x4ada24(_0x167eda+_0x5da93c+_0x28ad5a);_0x495ce4[_0x8b0d('0xe')](JSON['stringify']({'appID':_0x5da93c,'timestamp':_0x167eda,'appKey':_0x34ace9}));var _0x3d7869=fs[_0x8b0d('0xf')](_0x31496c);_0x3d7869['on'](_0x8b0d('0x10'),function(_0x1d9ab2){_0x495ce4[_0x8b0d('0xe')](_0x1d9ab2);});_0x3d7869['on'](_0x8b0d('0x11'),function(){_0x495ce4[_0x8b0d('0xe')](_0x8b0d('0x12'));});}catch(_0x7bd669){logger['error']('Tilde\x20ASR\x20send\x20error',JSON[_0x8b0d('0x13')](_0x7bd669));_0x495ce4[_0x8b0d('0x14')]();}}function _0x496648(_0x1eb688){try{if(_0x1eb688){var _0x353215=JSON[_0x8b0d('0x15')](_0x1eb688);switch(_0x353215[_0x8b0d('0x16')]){case 0x0:if(_0x353215[_0x8b0d('0x17')]){if(_0x353215[_0x8b0d('0x17')][_0x8b0d('0x18')]){logger[_0x8b0d('0x7')](_0x8b0d('0x19'),JSON['stringify'](_0x353215[_0x8b0d('0x17')][_0x8b0d('0x1a')]));_0xd46dfa=_0x353215['result']['hypotheses'][0x0]['transcript'];_0x5944be=_0x353215['result'][_0x8b0d('0x1a')][0x0][_0x8b0d('0x1b')];_0x7ebc4a='0';_0x5cba0a='Success.';_0x495ce4[_0x8b0d('0x14')]();}}break;case 0x1:logger['info']('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x7ebc4a='1';_0x5cba0a=_0x8b0d('0x1c');break;case 0x2:logger[_0x8b0d('0x7')](_0x8b0d('0x1d'));_0x7ebc4a='2';_0x5cba0a='Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.';break;case 0x9:logger[_0x8b0d('0x7')](_0x8b0d('0x1e'));_0x7ebc4a='9';_0x5cba0a=_0x8b0d('0x1e');break;case 0xa:logger['info'](_0x8b0d('0x1f'));_0x7ebc4a='10';_0x5cba0a=_0x8b0d('0x1f');break;case 0xb:logger[_0x8b0d('0x7')](_0x8b0d('0x20'));_0x7ebc4a='11';_0x5cba0a=_0x8b0d('0x20');}}}catch(_0x5e06b9){logger['error'](_0x8b0d('0x21'),JSON[_0x8b0d('0x13')](_0x5e06b9));_0x495ce4[_0x8b0d('0x14')]();}}function _0x3be36f(){logger[_0x8b0d('0x7')](_0x8b0d('0x22'));_0x1aad51({'transcript':_0xd46dfa,'confidence':_0x5944be,'status':_0x7ebc4a,'status_message':_0x5cba0a});}function _0x1e5313(_0x2424b2){logger['error'](_0x8b0d('0x23'));if(!_['isNil'](_0x2424b2)){logger[_0x8b0d('0x24')](_[_0x8b0d('0x25')](_0x2424b2)?JSON[_0x8b0d('0x13')](_0x2424b2):_0x2424b2);}}_0x495ce4['on'](_0x8b0d('0x26'),_0x756f3b);_0x495ce4['on']('message',_0x496648);_0x495ce4['on'](_0x8b0d('0x11'),_0x3be36f);_0x495ce4['on'](_0x8b0d('0x24'),_0x1e5313);});};
\ No newline at end of file
+var _0xf80b=['No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','createHash','sha1','update','digest','hex','info','unix','stringify','createReadStream','data','close','send','EOS','error','Tilde\x20ASR\x20send\x20error','terminate','parse','status','result','final','Tilde\x20ASR\x20hypoteses','transcript','likelihood','Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.','Not\x20available.\x20Max\x20load\x20limit\x20reached.','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','isNil','open','message','bluebird','lodash','moment','../../../../../../config/logger','agi','exports','Tilde\x20URI','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE'];(function(_0x4ae829,_0x2c842c){var _0x256b31=function(_0x34f104){while(--_0x34f104){_0x4ae829['push'](_0x4ae829['shift']());}};_0x256b31(++_0x2c842c);}(_0xf80b,0x19a));var _0xbf80=function(_0x4f223c,_0x360f21){_0x4f223c=_0x4f223c-0x0;var _0x452058=_0xf80b[_0x4f223c];return _0x452058;};'use strict';var BPromise=require(_0xbf80('0x0'));var _=require(_0xbf80('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0xbf80('0x2'));var crypto=require('crypto');var logger=require(_0xbf80('0x3'))(_0xbf80('0x4'));module[_0xbf80('0x5')]=function(_0x4a1ec5,_0x368a82,_0x46a883,_0x4f7dae){return new BPromise(function(_0x41c5f8,_0x3933ed){logger['info'](_0xbf80('0x6'),_0x4f7dae||_0xbf80('0x7'));var _0x41ea05=new WebSocket(_0x4f7dae||_0xbf80('0x7'),{'perMessageDeflate':![]});var _0x1ddc43='';var _0x3cdaf8='0';var _0xca97d0='1';var _0x1800d5=_0xbf80('0x8');function _0x339035(_0x5cc00f){var _0x21815b=crypto[_0xbf80('0x9')](_0xbf80('0xa'));_0x21815b[_0xbf80('0xb')](_0x5cc00f);return _0x21815b[_0xbf80('0xc')](_0xbf80('0xd'));}function _0x3b1d9d(){try{logger[_0xbf80('0xe')]('Open\x20Tilde\x20ASR\x20socket');var _0x252892=moment()[_0xbf80('0xf')]();var _0x4086ad=_0x339035(_0x252892+_0x368a82+_0x46a883);_0x41ea05['send'](JSON[_0xbf80('0x10')]({'appID':_0x368a82,'timestamp':_0x252892,'appKey':_0x4086ad}));var _0x374879=fs[_0xbf80('0x11')](_0x4a1ec5);_0x374879['on'](_0xbf80('0x12'),function(_0x55744a){_0x41ea05['send'](_0x55744a);});_0x374879['on'](_0xbf80('0x13'),function(){_0x41ea05[_0xbf80('0x14')](_0xbf80('0x15'));});}catch(_0x15674f){logger[_0xbf80('0x16')](_0xbf80('0x17'),JSON['stringify'](_0x15674f));_0x41ea05[_0xbf80('0x18')]();}}function _0x4380db(_0x15d08c){try{if(_0x15d08c){var _0x5ad3ce=JSON[_0xbf80('0x19')](_0x15d08c);switch(_0x5ad3ce[_0xbf80('0x1a')]){case 0x0:if(_0x5ad3ce[_0xbf80('0x1b')]){if(_0x5ad3ce[_0xbf80('0x1b')][_0xbf80('0x1c')]){logger[_0xbf80('0xe')](_0xbf80('0x1d'),JSON['stringify'](_0x5ad3ce[_0xbf80('0x1b')]['hypotheses']));_0x1ddc43=_0x5ad3ce[_0xbf80('0x1b')]['hypotheses'][0x0][_0xbf80('0x1e')];_0x3cdaf8=_0x5ad3ce[_0xbf80('0x1b')]['hypotheses'][0x0][_0xbf80('0x1f')];_0xca97d0='0';_0x1800d5='Success.';_0x41ea05[_0xbf80('0x18')]();}}break;case 0x1:logger['info'](_0xbf80('0x8'));_0xca97d0='1';_0x1800d5=_0xbf80('0x8');break;case 0x2:logger[_0xbf80('0xe')](_0xbf80('0x20'));_0xca97d0='2';_0x1800d5='Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.';break;case 0x9:logger['info'](_0xbf80('0x21'));_0xca97d0='9';_0x1800d5=_0xbf80('0x21');break;case 0xa:logger[_0xbf80('0xe')]('Authentication\x20failed.');_0xca97d0='10';_0x1800d5='Authentication\x20failed.';break;case 0xb:logger['info'](_0xbf80('0x22'));_0xca97d0='11';_0x1800d5=_0xbf80('0x22');}}}catch(_0x560036){logger[_0xbf80('0x16')]('Tilde\x20ASR\x20parse\x20error',JSON[_0xbf80('0x10')](_0x560036));_0x41ea05[_0xbf80('0x18')]();}}function _0x1147dc(){logger[_0xbf80('0xe')]('Close\x20Tilde\x20ASR\x20socket');_0x41c5f8({'transcript':_0x1ddc43,'confidence':_0x3cdaf8,'status':_0xca97d0,'status_message':_0x1800d5});}function _0x1a4618(_0x54f25c){logger[_0xbf80('0x16')]('Error\x20Tilde\x20ASR\x20socket');if(!_[_0xbf80('0x23')](_0x54f25c)){logger[_0xbf80('0x16')](_['isObject'](_0x54f25c)?JSON['stringify'](_0x54f25c):_0x54f25c);}}_0x41ea05['on'](_0xbf80('0x24'),_0x3b1d9d);_0x41ea05['on'](_0xbf80('0x25'),_0x4380db);_0x41ea05['on'](_0xbf80('0x13'),_0x1147dc);_0x41ea05['on'](_0xbf80('0x16'),_0x1a4618);});};
\ No newline at end of file