Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / services / agi / scripts / tilde / asr / lib / api.js
index 7eb3b03..47b9a7b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe7c2=['error','Tilde\x20ASR\x20send\x20error','terminate','status','result','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','isNil','isObject','open','message','close','bluebird','lodash','crypto','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','Open\x20Tilde\x20ASR\x20socket','stringify','createReadStream','data','send','EOS'];(function(_0x4ce028,_0x526d4b){var _0x583d0c=function(_0x874178){while(--_0x874178){_0x4ce028['push'](_0x4ce028['shift']());}};_0x583d0c(++_0x526d4b);}(_0xe7c2,0x117));var _0x2e7c=function(_0x4b75a0,_0x277c31){_0x4b75a0=_0x4b75a0-0x0;var _0x293430=_0xe7c2[_0x4b75a0];return _0x293430;};'use strict';var BPromise=require(_0x2e7c('0x0'));var _=require(_0x2e7c('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require('moment');var crypto=require(_0x2e7c('0x2'));var logger=require('../../../../../../config/logger')(_0x2e7c('0x3'));module[_0x2e7c('0x4')]=function(_0x1d0774,_0x1faa77,_0xe802bc,_0x2981e8){return new BPromise(function(_0x36b0b4,_0x4ca502){logger[_0x2e7c('0x5')](_0x2e7c('0x6'),_0x2981e8||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x488970=new WebSocket(_0x2981e8||_0x2e7c('0x7'),{'perMessageDeflate':![]});var _0x10f254='';var _0x4c9531='0';var _0x4ae54a='1';var _0x436afd=_0x2e7c('0x8');function _0x125f4f(_0x404971){var _0xa36c77=crypto['createHash'](_0x2e7c('0x9'));_0xa36c77['update'](_0x404971);return _0xa36c77[_0x2e7c('0xa')]('hex');}function _0xd81311(){try{logger['info'](_0x2e7c('0xb'));var _0xb99895=moment()['unix']();var _0x1cd81a=_0x125f4f(_0xb99895+_0x1faa77+_0xe802bc);_0x488970['send'](JSON[_0x2e7c('0xc')]({'appID':_0x1faa77,'timestamp':_0xb99895,'appKey':_0x1cd81a}));var _0x23be75=fs[_0x2e7c('0xd')](_0x1d0774);_0x23be75['on'](_0x2e7c('0xe'),function(_0xb462ce){_0x488970[_0x2e7c('0xf')](_0xb462ce);});_0x23be75['on']('close',function(){_0x488970['send'](_0x2e7c('0x10'));});}catch(_0x6e7a20){logger[_0x2e7c('0x11')](_0x2e7c('0x12'),JSON[_0x2e7c('0xc')](_0x6e7a20));_0x488970[_0x2e7c('0x13')]();}}function _0x1bffbf(_0x40170f){try{if(_0x40170f){var _0x326c6d=JSON['parse'](_0x40170f);switch(_0x326c6d[_0x2e7c('0x14')]){case 0x0:if(_0x326c6d[_0x2e7c('0x15')]){if(_0x326c6d[_0x2e7c('0x15')]['final']){logger[_0x2e7c('0x5')](_0x2e7c('0x16'),JSON['stringify'](_0x326c6d[_0x2e7c('0x15')][_0x2e7c('0x17')]));_0x10f254=_0x326c6d[_0x2e7c('0x15')][_0x2e7c('0x17')][0x0][_0x2e7c('0x18')];_0x4c9531=_0x326c6d[_0x2e7c('0x15')][_0x2e7c('0x17')][0x0][_0x2e7c('0x19')];_0x4ae54a='0';_0x436afd=_0x2e7c('0x1a');_0x488970[_0x2e7c('0x13')]();}}break;case 0x1:logger[_0x2e7c('0x5')](_0x2e7c('0x8'));_0x4ae54a='1';_0x436afd=_0x2e7c('0x8');break;case 0x2:logger[_0x2e7c('0x5')](_0x2e7c('0x1b'));_0x4ae54a='2';_0x436afd=_0x2e7c('0x1b');break;case 0x9:logger[_0x2e7c('0x5')](_0x2e7c('0x1c'));_0x4ae54a='9';_0x436afd=_0x2e7c('0x1c');break;case 0xa:logger[_0x2e7c('0x5')](_0x2e7c('0x1d'));_0x4ae54a='10';_0x436afd=_0x2e7c('0x1d');break;case 0xb:logger[_0x2e7c('0x5')](_0x2e7c('0x1e'));_0x4ae54a='11';_0x436afd=_0x2e7c('0x1e');}}}catch(_0x2ec207){logger[_0x2e7c('0x11')](_0x2e7c('0x1f'),JSON[_0x2e7c('0xc')](_0x2ec207));_0x488970[_0x2e7c('0x13')]();}}function _0x2fba8e(){logger[_0x2e7c('0x5')]('Close\x20Tilde\x20ASR\x20socket');_0x36b0b4({'transcript':_0x10f254,'confidence':_0x4c9531,'status':_0x4ae54a,'status_message':_0x436afd});}function _0x179474(_0x5b31eb){logger[_0x2e7c('0x11')]('Error\x20Tilde\x20ASR\x20socket');if(!_[_0x2e7c('0x20')](_0x5b31eb)){logger[_0x2e7c('0x11')](_[_0x2e7c('0x21')](_0x5b31eb)?JSON['stringify'](_0x5b31eb):_0x5b31eb);}}_0x488970['on'](_0x2e7c('0x22'),_0xd81311);_0x488970['on'](_0x2e7c('0x23'),_0x1bffbf);_0x488970['on'](_0x2e7c('0x24'),_0x2fba8e);_0x488970['on'](_0x2e7c('0x11'),_0x179474);});};
\ No newline at end of file
+var _0x20cc=['open','message','bluebird','lodash','moment','crypto','../../../../../../config/logger','exports','info','Tilde\x20URI','wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE','sha1','update','digest','hex','Open\x20Tilde\x20ASR\x20socket','unix','send','stringify','close','error','Tilde\x20ASR\x20send\x20error','terminate','parse','status','result','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.','Close\x20Tilde\x20ASR\x20socket','Error\x20Tilde\x20ASR\x20socket','isNil','isObject'];(function(_0x24f379,_0x4bfb5b){var _0x35e934=function(_0x260a20){while(--_0x260a20){_0x24f379['push'](_0x24f379['shift']());}};_0x35e934(++_0x4bfb5b);}(_0x20cc,0x74));var _0xc20c=function(_0x1ac595,_0x5d2081){_0x1ac595=_0x1ac595-0x0;var _0x455fff=_0x20cc[_0x1ac595];return _0x455fff;};'use strict';var BPromise=require(_0xc20c('0x0'));var _=require(_0xc20c('0x1'));var fs=require('fs');var WebSocket=require('ws');var moment=require(_0xc20c('0x2'));var crypto=require(_0xc20c('0x3'));var logger=require(_0xc20c('0x4'))('agi');module[_0xc20c('0x5')]=function(_0x43f91d,_0x449bb3,_0x65ad11,_0x1c8f6f){return new BPromise(function(_0xb140d5,_0xef80e5){logger[_0xc20c('0x6')](_0xc20c('0x7'),_0x1c8f6f||'wss://runa.tilde.lv/client/ws/speech/LVASR-ONLINE');var _0x6fac40=new WebSocket(_0x1c8f6f||_0xc20c('0x8'),{'perMessageDeflate':![]});var _0x529b3f='';var _0x2af5a0='0';var _0x103c7a='1';var _0x403f5e='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';function _0x20703f(_0x495f05){var _0x539b1c=crypto['createHash'](_0xc20c('0x9'));_0x539b1c[_0xc20c('0xa')](_0x495f05);return _0x539b1c[_0xc20c('0xb')](_0xc20c('0xc'));}function _0x5c3954(){try{logger['info'](_0xc20c('0xd'));var _0x50bbaf=moment()[_0xc20c('0xe')]();var _0x1b9de8=_0x20703f(_0x50bbaf+_0x449bb3+_0x65ad11);_0x6fac40[_0xc20c('0xf')](JSON[_0xc20c('0x10')]({'appID':_0x449bb3,'timestamp':_0x50bbaf,'appKey':_0x1b9de8}));var _0x46a003=fs['createReadStream'](_0x43f91d);_0x46a003['on']('data',function(_0x521c6a){_0x6fac40[_0xc20c('0xf')](_0x521c6a);});_0x46a003['on'](_0xc20c('0x11'),function(){_0x6fac40['send']('EOS');});}catch(_0x56814e){logger[_0xc20c('0x12')](_0xc20c('0x13'),JSON[_0xc20c('0x10')](_0x56814e));_0x6fac40[_0xc20c('0x14')]();}}function _0x337e63(_0x255c36){try{if(_0x255c36){var _0x4acd3d=JSON[_0xc20c('0x15')](_0x255c36);switch(_0x4acd3d[_0xc20c('0x16')]){case 0x0:if(_0x4acd3d[_0xc20c('0x17')]){if(_0x4acd3d[_0xc20c('0x17')]['final']){logger[_0xc20c('0x6')](_0xc20c('0x18'),JSON[_0xc20c('0x10')](_0x4acd3d[_0xc20c('0x17')][_0xc20c('0x19')]));_0x529b3f=_0x4acd3d[_0xc20c('0x17')][_0xc20c('0x19')][0x0][_0xc20c('0x1a')];_0x2af5a0=_0x4acd3d['result']['hypotheses'][0x0][_0xc20c('0x1b')];_0x103c7a='0';_0x403f5e='Success.';_0x6fac40[_0xc20c('0x14')]();}}break;case 0x1:logger[_0xc20c('0x6')]('No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech');_0x103c7a='1';_0x403f5e='No\x20speech.\x20Sent\x20when\x20the\x20incoming\x20audio\x20contains\x20a\x20large\x20portion\x20of\x20silence\x20or\x20non-speech';break;case 0x2:logger['info'](_0xc20c('0x1c'));_0x103c7a='2';_0x403f5e=_0xc20c('0x1c');break;case 0x9:logger[_0xc20c('0x6')]('Not\x20available.\x20Max\x20load\x20limit\x20reached.');_0x103c7a='9';_0x403f5e=_0xc20c('0x1d');break;case 0xa:logger[_0xc20c('0x6')](_0xc20c('0x1e'));_0x103c7a='10';_0x403f5e='Authentication\x20failed.';break;case 0xb:logger[_0xc20c('0x6')](_0xc20c('0x1f'));_0x103c7a='11';_0x403f5e=_0xc20c('0x1f');}}}catch(_0x61aede){logger[_0xc20c('0x12')]('Tilde\x20ASR\x20parse\x20error',JSON[_0xc20c('0x10')](_0x61aede));_0x6fac40['terminate']();}}function _0x58bd9b(){logger[_0xc20c('0x6')](_0xc20c('0x20'));_0xb140d5({'transcript':_0x529b3f,'confidence':_0x2af5a0,'status':_0x103c7a,'status_message':_0x403f5e});}function _0x23758e(_0x250855){logger[_0xc20c('0x12')](_0xc20c('0x21'));if(!_[_0xc20c('0x22')](_0x250855)){logger['error'](_[_0xc20c('0x23')](_0x250855)?JSON['stringify'](_0x250855):_0x250855);}}_0x6fac40['on'](_0xc20c('0x24'),_0x5c3954);_0x6fac40['on'](_0xc20c('0x25'),_0x337e63);_0x6fac40['on']('close',_0x58bd9b);_0x6fac40['on'](_0xc20c('0x12'),_0x23758e);});};
\ No newline at end of file