Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index b3fc4df..09936b0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x69f9=['createHash','update','digest','hex','Open\x20Tilde\x20ASR\x20socket','stringify','data','send','close','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','open','bluebird','lodash','moment','../../../../../../config/logger','agi','exports','info','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'];(function(_0x2f9467,_0x40576f){var _0x39894c=function(_0x13e344){while(--_0x13e344){_0x2f9467['push'](_0x2f9467['shift']());}};_0x39894c(++_0x40576f);}(_0x69f9,0x1bf));var _0x969f=function(_0x3f9607,_0x4439a8){_0x3f9607=_0x3f9607-0x0;var _0x5519ef=_0x69f9[_0x3f9607];return _0x5519ef;};'use strict';var BPromise=require(_0x969f('0x0'));var _=require(_0x969f('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x969f('0x2'));var crypto=require('crypto');var logger=require(_0x969f('0x3'))(_0x969f('0x4'));module[_0x969f('0x5')]=function(_0x47442c,_0x5c39c6,_0x29d6a1,_0x17bf96){return new BPromise(function(_0x4e77db,_0x23237f){logger[_0x969f('0x6')]('Tilde\x20URI',_0x17bf96||_0x969f('0x7'));var _0x47fc24=new WebSocket(_0x17bf96||_0x969f('0x7'),{'perMessageDeflate':![]});var _0x3444f9='';var _0xaf29ac='0';var _0x48667c='1';var _0x4c2b4d=_0x969f('0x8');function _0x19175a(_0x30212b){var _0x31f8ea=crypto[_0x969f('0x9')]('sha1');_0x31f8ea[_0x969f('0xa')](_0x30212b);return _0x31f8ea[_0x969f('0xb')](_0x969f('0xc'));}function _0x2d3ed3(){try{logger['info'](_0x969f('0xd'));var _0x201773=moment()['unix']();var _0x36f937=_0x19175a(_0x201773+_0x5c39c6+_0x29d6a1);_0x47fc24['send'](JSON[_0x969f('0xe')]({'appID':_0x5c39c6,'timestamp':_0x201773,'appKey':_0x36f937}));var _0x5d73ff=fs['createReadStream'](_0x47442c);_0x5d73ff['on'](_0x969f('0xf'),function(_0x57f608){_0x47fc24[_0x969f('0x10')](_0x57f608);});_0x5d73ff['on'](_0x969f('0x11'),function(){_0x47fc24[_0x969f('0x10')]('EOS');});}catch(_0x2febc){logger[_0x969f('0x12')](_0x969f('0x13'),JSON[_0x969f('0xe')](_0x2febc));_0x47fc24[_0x969f('0x14')]();}}function _0x194236(_0xbb33db){try{if(_0xbb33db){var _0xd3d07c=JSON[_0x969f('0x15')](_0xbb33db);switch(_0xd3d07c[_0x969f('0x16')]){case 0x0:if(_0xd3d07c[_0x969f('0x17')]){if(_0xd3d07c[_0x969f('0x17')][_0x969f('0x18')]){logger[_0x969f('0x6')](_0x969f('0x19'),JSON[_0x969f('0xe')](_0xd3d07c[_0x969f('0x17')]['hypotheses']));_0x3444f9=_0xd3d07c[_0x969f('0x17')][_0x969f('0x1a')][0x0][_0x969f('0x1b')];_0xaf29ac=_0xd3d07c['result'][_0x969f('0x1a')][0x0][_0x969f('0x1c')];_0x48667c='0';_0x4c2b4d=_0x969f('0x1d');_0x47fc24[_0x969f('0x14')]();}}break;case 0x1:logger[_0x969f('0x6')](_0x969f('0x8'));_0x48667c='1';_0x4c2b4d=_0x969f('0x8');break;case 0x2:logger[_0x969f('0x6')]('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.');_0x48667c='2';_0x4c2b4d=_0x969f('0x1e');break;case 0x9:logger[_0x969f('0x6')](_0x969f('0x1f'));_0x48667c='9';_0x4c2b4d=_0x969f('0x1f');break;case 0xa:logger[_0x969f('0x6')](_0x969f('0x20'));_0x48667c='10';_0x4c2b4d=_0x969f('0x20');break;case 0xb:logger['info'](_0x969f('0x21'));_0x48667c='11';_0x4c2b4d='All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.';}}}catch(_0x734616){logger[_0x969f('0x12')](_0x969f('0x22'),JSON[_0x969f('0xe')](_0x734616));_0x47fc24[_0x969f('0x14')]();}}function _0x2de036(){logger[_0x969f('0x6')]('Close\x20Tilde\x20ASR\x20socket');_0x4e77db({'transcript':_0x3444f9,'confidence':_0xaf29ac,'status':_0x48667c,'status_message':_0x4c2b4d});}function _0x405a5b(_0x3db45c){logger['error'](_0x969f('0x23'));if(!_[_0x969f('0x24')](_0x3db45c)){logger['error'](_['isObject'](_0x3db45c)?JSON[_0x969f('0xe')](_0x3db45c):_0x3db45c);}}_0x47fc24['on'](_0x969f('0x25'),_0x2d3ed3);_0x47fc24['on']('message',_0x194236);_0x47fc24['on'](_0x969f('0x11'),_0x2de036);_0x47fc24['on'](_0x969f('0x12'),_0x405a5b);});};
\ No newline at end of file
+var _0x87d9=['result','Tilde\x20ASR\x20hypoteses','hypotheses','Success.','No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech','Not\x20available.\x20Max\x20load\x20limit\x20reached.','Authentication\x20failed.','All\x20recognition\x20workers\x20are\x20currently\x20in\x20use\x20and\x20real-time\x20recognition\x20is\x20not\x20possible.','Close\x20Tilde\x20ASR\x20socket','Error\x20Tilde\x20ASR\x20socket','isNil','isObject','open','message','close','moment','crypto','../../../../../../config/logger','agi','exports','info','Tilde\x20URI','update','digest','hex','unix','send','data','EOS','error','Tilde\x20ASR\x20send\x20error','stringify','terminate','parse','status'];(function(_0x257642,_0x270a80){var _0x3d813b=function(_0x2a1c8a){while(--_0x2a1c8a){_0x257642['push'](_0x257642['shift']());}};_0x3d813b(++_0x270a80);}(_0x87d9,0x127));var _0x987d=function(_0x548eae,_0xad69de){_0x548eae=_0x548eae-0x0;var _0x5b1a01=_0x87d9[_0x548eae];return _0x5b1a01;};'use strict';var BPromise=require('bluebird');var _=require('lodash');var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x987d('0x0'));var crypto=require(_0x987d('0x1'));var logger=require(_0x987d('0x2'))(_0x987d('0x3'));module[_0x987d('0x4')]=function(_0x4eeda4,_0x3e4f55,_0x4ce97c,_0x433a55){return new BPromise(function(_0x2970f4,_0x14297e){logger[_0x987d('0x5')](_0x987d('0x6'),_0x433a55||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x5ac197=new WebSocket(_0x433a55||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE',{'perMessageDeflate':![]});var _0x597657='';var _0x20dc8c='0';var _0x4ae0bd='1';var _0x22b7d6='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x4b48e0(_0x304a41){var _0xaca8e9=crypto['createHash']('sha1');_0xaca8e9[_0x987d('0x7')](_0x304a41);return _0xaca8e9[_0x987d('0x8')](_0x987d('0x9'));}function _0x448280(){try{logger[_0x987d('0x5')]('Open\x20Tilde\x20ASR\x20socket');var _0x5b1c07=moment()[_0x987d('0xa')]();var _0x2a2003=_0x4b48e0(_0x5b1c07+_0x3e4f55+_0x4ce97c);_0x5ac197[_0x987d('0xb')](JSON['stringify']({'appID':_0x3e4f55,'timestamp':_0x5b1c07,'appKey':_0x2a2003}));var _0x4586cd=fs['createReadStream'](_0x4eeda4);_0x4586cd['on'](_0x987d('0xc'),function(_0x2a175a){_0x5ac197[_0x987d('0xb')](_0x2a175a);});_0x4586cd['on']('close',function(){_0x5ac197[_0x987d('0xb')](_0x987d('0xd'));});}catch(_0xa89e4){logger[_0x987d('0xe')](_0x987d('0xf'),JSON[_0x987d('0x10')](_0xa89e4));_0x5ac197[_0x987d('0x11')]();}}function _0x536161(_0x1e1ad6){try{if(_0x1e1ad6){var _0x5e0a6e=JSON[_0x987d('0x12')](_0x1e1ad6);switch(_0x5e0a6e[_0x987d('0x13')]){case 0x0:if(_0x5e0a6e[_0x987d('0x14')]){if(_0x5e0a6e[_0x987d('0x14')]['final']){logger[_0x987d('0x5')](_0x987d('0x15'),JSON[_0x987d('0x10')](_0x5e0a6e[_0x987d('0x14')]['hypotheses']));_0x597657=_0x5e0a6e['result'][_0x987d('0x16')][0x0]['transcript'];_0x20dc8c=_0x5e0a6e['result'][_0x987d('0x16')][0x0]['likelihood'];_0x4ae0bd='0';_0x22b7d6=_0x987d('0x17');_0x5ac197['terminate']();}}break;case 0x1:logger[_0x987d('0x5')](_0x987d('0x18'));_0x4ae0bd='1';_0x22b7d6=_0x987d('0x18');break;case 0x2:logger[_0x987d('0x5')]('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.');_0x4ae0bd='2';_0x22b7d6='Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.';break;case 0x9:logger[_0x987d('0x5')](_0x987d('0x19'));_0x4ae0bd='9';_0x22b7d6=_0x987d('0x19');break;case 0xa:logger['info']('Authentication\x20failed.');_0x4ae0bd='10';_0x22b7d6=_0x987d('0x1a');break;case 0xb:logger['info'](_0x987d('0x1b'));_0x4ae0bd='11';_0x22b7d6=_0x987d('0x1b');}}}catch(_0x239abc){logger[_0x987d('0xe')]('Tilde\x20ASR\x20parse\x20error',JSON['stringify'](_0x239abc));_0x5ac197['terminate']();}}function _0x4c7fa5(){logger[_0x987d('0x5')](_0x987d('0x1c'));_0x2970f4({'transcript':_0x597657,'confidence':_0x20dc8c,'status':_0x4ae0bd,'status_message':_0x22b7d6});}function _0x54fff2(_0x2f8010){logger[_0x987d('0xe')](_0x987d('0x1d'));if(!_[_0x987d('0x1e')](_0x2f8010)){logger[_0x987d('0xe')](_[_0x987d('0x1f')](_0x2f8010)?JSON[_0x987d('0x10')](_0x2f8010):_0x2f8010);}}_0x5ac197['on'](_0x987d('0x20'),_0x448280);_0x5ac197['on'](_0x987d('0x21'),_0x536161);_0x5ac197['on'](_0x987d('0x22'),_0x4c7fa5);_0x5ac197['on'](_0x987d('0xe'),_0x54fff2);});};
\ No newline at end of file