Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 7ab8e46..2e22d05 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x50f9=['error','Tilde\x20ASR\x20send\x20error','terminate','parse','status','result','final','Tilde\x20ASR\x20hypoteses','hypotheses','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','Error\x20Tilde\x20ASR\x20socket','isNil','open','bluebird','lodash','moment','crypto','../../../../../../config/logger','agi','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','update','digest','hex','Open\x20Tilde\x20ASR\x20socket','unix','send','stringify','createReadStream','data','close','EOS'];(function(_0x46ef9d,_0xbc9e08){var _0x391eb0=function(_0x2deeca){while(--_0x2deeca){_0x46ef9d['push'](_0x46ef9d['shift']());}};_0x391eb0(++_0xbc9e08);}(_0x50f9,0x164));var _0x950f=function(_0x74731e,_0x2f8984){_0x74731e=_0x74731e-0x0;var _0x38d7da=_0x50f9[_0x74731e];return _0x38d7da;};'use strict';var BPromise=require(_0x950f('0x0'));var _=require(_0x950f('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0x950f('0x2'));var crypto=require(_0x950f('0x3'));var logger=require(_0x950f('0x4'))(_0x950f('0x5'));module['exports']=function(_0x57e669,_0x37bc6f,_0x25b35a,_0x837ab3){return new BPromise(function(_0x5e8b3f,_0x54c618){logger[_0x950f('0x6')](_0x950f('0x7'),_0x837ab3||_0x950f('0x8'));var _0x54d8cb=new WebSocket(_0x837ab3||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE',{'perMessageDeflate':![]});var _0x261477='';var _0x7a6ce5='0';var _0x3d34a4='1';var _0x2fdc0f=_0x950f('0x9');function _0x4aa854(_0x32537e){var _0x3c0a74=crypto['createHash'](_0x950f('0xa'));_0x3c0a74[_0x950f('0xb')](_0x32537e);return _0x3c0a74[_0x950f('0xc')](_0x950f('0xd'));}function _0x418cc2(){try{logger['info'](_0x950f('0xe'));var _0x4a5035=moment()[_0x950f('0xf')]();var _0x4d1264=_0x4aa854(_0x4a5035+_0x37bc6f+_0x25b35a);_0x54d8cb[_0x950f('0x10')](JSON[_0x950f('0x11')]({'appID':_0x37bc6f,'timestamp':_0x4a5035,'appKey':_0x4d1264}));var _0x4f4d3b=fs[_0x950f('0x12')](_0x57e669);_0x4f4d3b['on'](_0x950f('0x13'),function(_0x160caf){_0x54d8cb[_0x950f('0x10')](_0x160caf);});_0x4f4d3b['on'](_0x950f('0x14'),function(){_0x54d8cb['send'](_0x950f('0x15'));});}catch(_0x225bde){logger[_0x950f('0x16')](_0x950f('0x17'),JSON['stringify'](_0x225bde));_0x54d8cb[_0x950f('0x18')]();}}function _0x3c8c71(_0x54d8ea){try{if(_0x54d8ea){var _0x587fde=JSON[_0x950f('0x19')](_0x54d8ea);switch(_0x587fde[_0x950f('0x1a')]){case 0x0:if(_0x587fde[_0x950f('0x1b')]){if(_0x587fde[_0x950f('0x1b')][_0x950f('0x1c')]){logger[_0x950f('0x6')](_0x950f('0x1d'),JSON[_0x950f('0x11')](_0x587fde[_0x950f('0x1b')]['hypotheses']));_0x261477=_0x587fde[_0x950f('0x1b')][_0x950f('0x1e')][0x0][_0x950f('0x1f')];_0x7a6ce5=_0x587fde['result']['hypotheses'][0x0][_0x950f('0x20')];_0x3d34a4='0';_0x2fdc0f='Success.';_0x54d8cb[_0x950f('0x18')]();}}break;case 0x1:logger[_0x950f('0x6')]('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x3d34a4='1';_0x2fdc0f='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';break;case 0x2:logger['info']('Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.');_0x3d34a4='2';_0x2fdc0f=_0x950f('0x21');break;case 0x9:logger['info'](_0x950f('0x22'));_0x3d34a4='9';_0x2fdc0f='Not\x20available.\x20Max\x20load\x20limit\x20reached.';break;case 0xa:logger['info'](_0x950f('0x23'));_0x3d34a4='10';_0x2fdc0f=_0x950f('0x23');break;case 0xb:logger[_0x950f('0x6')](_0x950f('0x24'));_0x3d34a4='11';_0x2fdc0f=_0x950f('0x24');}}}catch(_0x8b0808){logger['error'](_0x950f('0x25'),JSON[_0x950f('0x11')](_0x8b0808));_0x54d8cb[_0x950f('0x18')]();}}function _0x572e15(){logger[_0x950f('0x6')](_0x950f('0x26'));_0x5e8b3f({'transcript':_0x261477,'confidence':_0x7a6ce5,'status':_0x3d34a4,'status_message':_0x2fdc0f});}function _0x4e49c0(_0x22b0cc){logger[_0x950f('0x16')](_0x950f('0x27'));if(!_[_0x950f('0x28')](_0x22b0cc)){logger[_0x950f('0x16')](_['isObject'](_0x22b0cc)?JSON['stringify'](_0x22b0cc):_0x22b0cc);}}_0x54d8cb['on'](_0x950f('0x29'),_0x418cc2);_0x54d8cb['on']('message',_0x3c8c71);_0x54d8cb['on'](_0x950f('0x14'),_0x572e15);_0x54d8cb['on'](_0x950f('0x16'),_0x4e49c0);});};
\ No newline at end of file
+var _0x3582=['wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','sha1','update','digest','info','Open\x20Tilde\x20ASR\x20socket','unix','stringify','createReadStream','data','send','close','error','terminate','status','result','Tilde\x20ASR\x20hypoteses','hypotheses','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.','Close\x20Tilde\x20ASR\x20socket','isNil','isObject','message','bluebird','lodash','../../../../../../config/logger','agi','exports','Tilde\x20URI'];(function(_0x13015c,_0x23da80){var _0x2d28b0=function(_0x6783c7){while(--_0x6783c7){_0x13015c['push'](_0x13015c['shift']());}};_0x2d28b0(++_0x23da80);}(_0x3582,0x9f));var _0x2358=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x3582[_0x3dd15e];return _0x231fd0;};'use strict';var BPromise=require(_0x2358('0x0'));var _=require(_0x2358('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require('moment');var crypto=require('crypto');var logger=require(_0x2358('0x2'))(_0x2358('0x3'));module[_0x2358('0x4')]=function(_0x56d11e,_0x44f268,_0x3e154c,_0x5a7119){return new BPromise(function(_0x1b846a,_0x5dc5e9){logger['info'](_0x2358('0x5'),_0x5a7119||_0x2358('0x6'));var _0x15b7cb=new WebSocket(_0x5a7119||_0x2358('0x6'),{'perMessageDeflate':![]});var _0x167d95='';var _0x574fd7='0';var _0x3cfc23='1';var _0x46543f='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x821e9f(_0x1bd2b6){var _0x771165=crypto['createHash'](_0x2358('0x7'));_0x771165[_0x2358('0x8')](_0x1bd2b6);return _0x771165[_0x2358('0x9')]('hex');}function _0x4dd42b(){try{logger[_0x2358('0xa')](_0x2358('0xb'));var _0x5169cf=moment()[_0x2358('0xc')]();var _0x33a900=_0x821e9f(_0x5169cf+_0x44f268+_0x3e154c);_0x15b7cb['send'](JSON[_0x2358('0xd')]({'appID':_0x44f268,'timestamp':_0x5169cf,'appKey':_0x33a900}));var _0x4660ec=fs[_0x2358('0xe')](_0x56d11e);_0x4660ec['on'](_0x2358('0xf'),function(_0xe4d7db){_0x15b7cb[_0x2358('0x10')](_0xe4d7db);});_0x4660ec['on'](_0x2358('0x11'),function(){_0x15b7cb['send']('EOS');});}catch(_0x5422a3){logger[_0x2358('0x12')]('Tilde\x20ASR\x20send\x20error',JSON['stringify'](_0x5422a3));_0x15b7cb[_0x2358('0x13')]();}}function _0x32bd23(_0x585afc){try{if(_0x585afc){var _0x2c3c4c=JSON['parse'](_0x585afc);switch(_0x2c3c4c[_0x2358('0x14')]){case 0x0:if(_0x2c3c4c[_0x2358('0x15')]){if(_0x2c3c4c[_0x2358('0x15')]['final']){logger['info'](_0x2358('0x16'),JSON[_0x2358('0xd')](_0x2c3c4c['result'][_0x2358('0x17')]));_0x167d95=_0x2c3c4c[_0x2358('0x15')][_0x2358('0x17')][0x0]['transcript'];_0x574fd7=_0x2c3c4c[_0x2358('0x15')][_0x2358('0x17')][0x0][_0x2358('0x18')];_0x3cfc23='0';_0x46543f='Success.';_0x15b7cb[_0x2358('0x13')]();}}break;case 0x1:logger[_0x2358('0xa')]('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x3cfc23='1';_0x46543f='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';break;case 0x2:logger['info'](_0x2358('0x19'));_0x3cfc23='2';_0x46543f='Aborted.\x20Recognition\x20was\x20aborted\x20for\x20some\x20reason.';break;case 0x9:logger['info'](_0x2358('0x1a'));_0x3cfc23='9';_0x46543f='Not\x20available.\x20Max\x20load\x20limit\x20reached.';break;case 0xa:logger[_0x2358('0xa')](_0x2358('0x1b'));_0x3cfc23='10';_0x46543f='Authentication\x20failed.';break;case 0xb:logger[_0x2358('0xa')](_0x2358('0x1c'));_0x3cfc23='11';_0x46543f=_0x2358('0x1c');}}}catch(_0x53dc06){logger[_0x2358('0x12')]('Tilde\x20ASR\x20parse\x20error',JSON[_0x2358('0xd')](_0x53dc06));_0x15b7cb[_0x2358('0x13')]();}}function _0x2bfb82(){logger[_0x2358('0xa')](_0x2358('0x1d'));_0x1b846a({'transcript':_0x167d95,'confidence':_0x574fd7,'status':_0x3cfc23,'status_message':_0x46543f});}function _0x2dea8f(_0x51b685){logger[_0x2358('0x12')]('Error\x20Tilde\x20ASR\x20socket');if(!_[_0x2358('0x1e')](_0x51b685)){logger[_0x2358('0x12')](_[_0x2358('0x1f')](_0x51b685)?JSON[_0x2358('0xd')](_0x51b685):_0x51b685);}}_0x15b7cb['on']('open',_0x4dd42b);_0x15b7cb['on'](_0x2358('0x20'),_0x32bd23);_0x15b7cb['on'](_0x2358('0x11'),_0x2bfb82);_0x15b7cb['on'](_0x2358('0x12'),_0x2dea8f);});};
\ No newline at end of file