Built motion from commit fda31434.|2.5.44
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 782c79e..3ab0ac8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa936=['info','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','hex','Open\x20Tilde\x20ASR\x20socket','send','stringify','data','error','Tilde\x20ASR\x20send\x20error','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','transcript','likelihood','Success.','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','isObject','message','close','bluebird','crypto','../../../../../../config/logger','agi','exports'];(function(_0x1d4eed,_0x4922b2){var _0x10911b=function(_0x5422ab){while(--_0x5422ab){_0x1d4eed['push'](_0x1d4eed['shift']());}};_0x10911b(++_0x4922b2);}(_0xa936,0xb4));var _0x6a93=function(_0x29d94e,_0xf386d6){_0x29d94e=_0x29d94e-0x0;var _0x106237=_0xa936[_0x29d94e];return _0x106237;};'use strict';var BPromise=require(_0x6a93('0x0'));var _=require('lodash');var fs=require('fs');var WebSocket=require('ws');var moment=require('moment');var crypto=require(_0x6a93('0x1'));var logger=require(_0x6a93('0x2'))(_0x6a93('0x3'));module[_0x6a93('0x4')]=function(_0x529432,_0x18ed25,_0x3fd346,_0x89e24d){return new BPromise(function(_0x2ab1cd,_0x3ef07f){logger[_0x6a93('0x5')](_0x6a93('0x6'),_0x89e24d||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x1a96a2=new WebSocket(_0x89e24d||_0x6a93('0x7'),{'perMessageDeflate':![]});var _0x1a4ad3='';var _0x38383b='0';var _0x320904='1';var _0x4a7821=_0x6a93('0x8');function _0x67d55e(_0x1a9a7b){var _0x34111f=crypto[_0x6a93('0x9')](_0x6a93('0xa'));_0x34111f[_0x6a93('0xb')](_0x1a9a7b);return _0x34111f['digest'](_0x6a93('0xc'));}function _0x3897f2(){try{logger['info'](_0x6a93('0xd'));var _0x4767b9=moment()['unix']();var _0x64bd7e=_0x67d55e(_0x4767b9+_0x18ed25+_0x3fd346);_0x1a96a2[_0x6a93('0xe')](JSON[_0x6a93('0xf')]({'appID':_0x18ed25,'timestamp':_0x4767b9,'appKey':_0x64bd7e}));var _0x532745=fs['createReadStream'](_0x529432);_0x532745['on'](_0x6a93('0x10'),function(_0x98a6b1){_0x1a96a2[_0x6a93('0xe')](_0x98a6b1);});_0x532745['on']('close',function(){_0x1a96a2['send']('EOS');});}catch(_0x31626d){logger[_0x6a93('0x11')](_0x6a93('0x12'),JSON[_0x6a93('0xf')](_0x31626d));_0x1a96a2['terminate']();}}function _0x568e06(_0x5821d8){try{if(_0x5821d8){var _0x4f269a=JSON['parse'](_0x5821d8);switch(_0x4f269a['status']){case 0x0:if(_0x4f269a[_0x6a93('0x13')]){if(_0x4f269a[_0x6a93('0x13')][_0x6a93('0x14')]){logger[_0x6a93('0x5')](_0x6a93('0x15'),JSON[_0x6a93('0xf')](_0x4f269a[_0x6a93('0x13')][_0x6a93('0x16')]));_0x1a4ad3=_0x4f269a['result'][_0x6a93('0x16')][0x0][_0x6a93('0x17')];_0x38383b=_0x4f269a[_0x6a93('0x13')][_0x6a93('0x16')][0x0][_0x6a93('0x18')];_0x320904='0';_0x4a7821=_0x6a93('0x19');_0x1a96a2[_0x6a93('0x1a')]();}}break;case 0x1:logger[_0x6a93('0x5')](_0x6a93('0x8'));_0x320904='1';_0x4a7821='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';break;case 0x2:logger[_0x6a93('0x5')](_0x6a93('0x1b'));_0x320904='2';_0x4a7821=_0x6a93('0x1b');break;case 0x9:logger[_0x6a93('0x5')](_0x6a93('0x1c'));_0x320904='9';_0x4a7821=_0x6a93('0x1c');break;case 0xa:logger[_0x6a93('0x5')]('Authentication\x20failed.');_0x320904='10';_0x4a7821=_0x6a93('0x1d');break;case 0xb:logger[_0x6a93('0x5')](_0x6a93('0x1e'));_0x320904='11';_0x4a7821=_0x6a93('0x1e');}}}catch(_0x5b27fc){logger[_0x6a93('0x11')](_0x6a93('0x1f'),JSON[_0x6a93('0xf')](_0x5b27fc));_0x1a96a2[_0x6a93('0x1a')]();}}function _0xe8bb64(){logger[_0x6a93('0x5')](_0x6a93('0x20'));_0x2ab1cd({'transcript':_0x1a4ad3,'confidence':_0x38383b,'status':_0x320904,'status_message':_0x4a7821});}function _0x3acb4f(_0x5c28c4){logger[_0x6a93('0x11')](_0x6a93('0x21'));if(!_['isNil'](_0x5c28c4)){logger[_0x6a93('0x11')](_[_0x6a93('0x22')](_0x5c28c4)?JSON[_0x6a93('0xf')](_0x5c28c4):_0x5c28c4);}}_0x1a96a2['on']('open',_0x3897f2);_0x1a96a2['on'](_0x6a93('0x23'),_0x568e06);_0x1a96a2['on'](_0x6a93('0x24'),_0xe8bb64);_0x1a96a2['on']('error',_0x3acb4f);});};
\ No newline at end of file
+var _0xf9c6=['parse','result','final','Tilde\x20ASR\x20hypoteses','transcript','likelihood','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','isObject','open','message','bluebird','lodash','moment','crypto','../../../../../../config/logger','agi','exports','info','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','sha1','digest','hex','Open\x20Tilde\x20ASR\x20socket','unix','send','createReadStream','data','close','EOS','error','Tilde\x20ASR\x20send\x20error','stringify','terminate'];(function(_0x5236eb,_0x3e1f44){var _0x1a47ec=function(_0x401ba1){while(--_0x401ba1){_0x5236eb['push'](_0x5236eb['shift']());}};_0x1a47ec(++_0x3e1f44);}(_0xf9c6,0xaf));var _0x6f9c=function(_0x9a7875,_0x31a4f9){_0x9a7875=_0x9a7875-0x0;var _0x29fc71=_0xf9c6[_0x9a7875];return _0x29fc71;};'use strict';var BPromise=require(_0x6f9c('0x0'));var _=require(_0x6f9c('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x6f9c('0x2'));var crypto=require(_0x6f9c('0x3'));var logger=require(_0x6f9c('0x4'))(_0x6f9c('0x5'));module[_0x6f9c('0x6')]=function(_0x238a05,_0x38a006,_0x4af11a,_0x2746ea){return new BPromise(function(_0x4749df,_0x9b077e){logger[_0x6f9c('0x7')](_0x6f9c('0x8'),_0x2746ea||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x49eb5d=new WebSocket(_0x2746ea||_0x6f9c('0x9'),{'perMessageDeflate':![]});var _0x10990e='';var _0x58918c='0';var _0x2bf36f='1';var _0x3424f2=_0x6f9c('0xa');function _0x126d43(_0x4a9993){var _0xfeb5b4=crypto['createHash'](_0x6f9c('0xb'));_0xfeb5b4['update'](_0x4a9993);return _0xfeb5b4[_0x6f9c('0xc')](_0x6f9c('0xd'));}function _0xdcdd0f(){try{logger[_0x6f9c('0x7')](_0x6f9c('0xe'));var _0x32ea6f=moment()[_0x6f9c('0xf')]();var _0x5dea3d=_0x126d43(_0x32ea6f+_0x38a006+_0x4af11a);_0x49eb5d[_0x6f9c('0x10')](JSON['stringify']({'appID':_0x38a006,'timestamp':_0x32ea6f,'appKey':_0x5dea3d}));var _0x3d2917=fs[_0x6f9c('0x11')](_0x238a05);_0x3d2917['on'](_0x6f9c('0x12'),function(_0x4a38bc){_0x49eb5d[_0x6f9c('0x10')](_0x4a38bc);});_0x3d2917['on'](_0x6f9c('0x13'),function(){_0x49eb5d[_0x6f9c('0x10')](_0x6f9c('0x14'));});}catch(_0x5efb9e){logger[_0x6f9c('0x15')](_0x6f9c('0x16'),JSON[_0x6f9c('0x17')](_0x5efb9e));_0x49eb5d[_0x6f9c('0x18')]();}}function _0x42b055(_0x4d7c60){try{if(_0x4d7c60){var _0x22fa51=JSON[_0x6f9c('0x19')](_0x4d7c60);switch(_0x22fa51['status']){case 0x0:if(_0x22fa51['result']){if(_0x22fa51[_0x6f9c('0x1a')][_0x6f9c('0x1b')]){logger[_0x6f9c('0x7')](_0x6f9c('0x1c'),JSON[_0x6f9c('0x17')](_0x22fa51[_0x6f9c('0x1a')]['hypotheses']));_0x10990e=_0x22fa51[_0x6f9c('0x1a')]['hypotheses'][0x0][_0x6f9c('0x1d')];_0x58918c=_0x22fa51[_0x6f9c('0x1a')]['hypotheses'][0x0][_0x6f9c('0x1e')];_0x2bf36f='0';_0x3424f2='Success.';_0x49eb5d['terminate']();}}break;case 0x1:logger[_0x6f9c('0x7')]('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x2bf36f='1';_0x3424f2=_0x6f9c('0xa');break;case 0x2:logger[_0x6f9c('0x7')](_0x6f9c('0x1f'));_0x2bf36f='2';_0x3424f2='Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.';break;case 0x9:logger['info']('Not\x20available.\x20Max\x20load\x20limit\x20reached.');_0x2bf36f='9';_0x3424f2=_0x6f9c('0x20');break;case 0xa:logger[_0x6f9c('0x7')]('Authentication\x20failed.');_0x2bf36f='10';_0x3424f2=_0x6f9c('0x21');break;case 0xb:logger[_0x6f9c('0x7')](_0x6f9c('0x22'));_0x2bf36f='11';_0x3424f2=_0x6f9c('0x22');}}}catch(_0x5f19a3){logger[_0x6f9c('0x15')](_0x6f9c('0x23'),JSON[_0x6f9c('0x17')](_0x5f19a3));_0x49eb5d[_0x6f9c('0x18')]();}}function _0x38f90b(){logger[_0x6f9c('0x7')](_0x6f9c('0x24'));_0x4749df({'transcript':_0x10990e,'confidence':_0x58918c,'status':_0x2bf36f,'status_message':_0x3424f2});}function _0x4eeb7d(_0xafec82){logger[_0x6f9c('0x15')]('Error\x20Tilde\x20ASR\x20socket');if(!_['isNil'](_0xafec82)){logger[_0x6f9c('0x15')](_[_0x6f9c('0x25')](_0xafec82)?JSON[_0x6f9c('0x17')](_0xafec82):_0xafec82);}}_0x49eb5d['on'](_0x6f9c('0x26'),_0xdcdd0f);_0x49eb5d['on'](_0x6f9c('0x27'),_0x42b055);_0x49eb5d['on']('close',_0x38f90b);_0x49eb5d['on'](_0x6f9c('0x15'),_0x4eeb7d);});};
\ No newline at end of file