Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / services / agi / scripts / index.js
index 3febfd0..c96a973 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x06de=['request\x20to\x20','\x20failed,\x20status\x20code\x20=\x20','statusMessage','createWriteStream','close','error','download\x20error','pipe','end','data','wav','error\x20convert','info','finish\x20to\x20convert','start','resolve','tmp','generate','.wav','writeFileSync','base64','unlink','chmodSync','777','split','readFileSync','toString','googleCloudTTS','https://texttospeech.googleapis.com/v1/','?key=','ssml','input','voice','audioConfig','MP3','POST','then','from','audioContent','writeFile','.mp3','goggleTTS\x20path','asr','results','map','alternatives','transcript','join','confidence','googleASR\x20transcription','catch','[%s]\x20%s:%s','name','googleDialogflow','textRequest','stringify','result','source','resolvedQuery','action','actionIncomplete','speech','status','code','metadata','tildeASR','Tilde\x20ASR\x20transcription','Tilde\x20ASR\x20confidence','awsPolly','polly','awsLex','lex','format','%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3','ispeechASR','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','model=%s','parse','sestekNDA','nda','text','channelData','AudioFromTts','Data','audiofile','dirName','path','http','https','url','bluebird','randomstring','sox','request-promise','util','querystring','google-tts-api','apiai-promise','./google','./aws','./tilde','./sestek','../../../config/logger','agi','https://api.ispeech.org/api/rest','protocol','https:','host','WHAT_EVER','get','statusCode'];(function(_0x37767,_0x1bef36){var _0x4aa26d=function(_0x5afa31){while(--_0x5afa31){_0x37767['push'](_0x37767['shift']());}};_0x4aa26d(++_0x1bef36);}(_0x06de,0x1a3));var _0xe06d=function(_0x5e7514,_0x30c2e1){_0x5e7514=_0x5e7514-0x0;var _0x12f472=_0x06de[_0x5e7514];return _0x12f472;};'use strict';var fs=require('fs');var path=require(_0xe06d('0x0'));var http=require(_0xe06d('0x1'));var https=require(_0xe06d('0x2'));var urlParse=require(_0xe06d('0x3'))['parse'];var BPromise=require(_0xe06d('0x4'));var rs=require(_0xe06d('0x5'));var sox=require(_0xe06d('0x6'));var rp=require(_0xe06d('0x7'));var util=require(_0xe06d('0x8'));var querystring=require(_0xe06d('0x9'));var tts=require(_0xe06d('0xa'));var apiai=require(_0xe06d('0xb'));var md5=require('md5');var google=require(_0xe06d('0xc'));var aws=require(_0xe06d('0xd'));var tilde=require(_0xe06d('0xe'));var sestek=require(_0xe06d('0xf'));var logger=require(_0xe06d('0x10'))(_0xe06d('0x11'));var ISPEECH_API=_0xe06d('0x12');function downloadFile(_0x5a7948,_0x27a02d){return new BPromise(function(_0x322424,_0x42463d){var _0x524aef=urlParse(_0x5a7948);var _0x512448=_0x524aef[_0xe06d('0x13')]===_0xe06d('0x14')?https:http;var _0x231ee3={'host':_0x524aef[_0xe06d('0x15')],'path':_0x524aef[_0xe06d('0x0')],'headers':{'user-agent':_0xe06d('0x16')}};_0x512448[_0xe06d('0x17')](_0x231ee3,function(_0x8401ce){if(_0x8401ce[_0xe06d('0x18')]!==0xc8){logger['error'](_0xe06d('0x19')+_0x5a7948+_0xe06d('0x1a')+_0x8401ce[_0xe06d('0x18')]+'\x20('+_0x8401ce[_0xe06d('0x1b')]+')');_0x42463d(new Error('request\x20to\x20'+_0x5a7948+_0xe06d('0x1a')+_0x8401ce['statusCode']+'\x20('+_0x8401ce['statusMessage']+')'));return;}var _0x30ed8b=fs[_0xe06d('0x1c')](_0x27a02d);_0x30ed8b['on']('finish',function(){logger['info']('finish\x20download\x20file');_0x30ed8b[_0xe06d('0x1d')](_0x322424);});_0x30ed8b['on'](_0xe06d('0x1e'),function(_0x62ee39){fs['unlink'](_0x27a02d);logger['error'](_0xe06d('0x1f'),_0x62ee39);_0x42463d(_0x62ee39);});_0x8401ce[_0xe06d('0x20')](_0x30ed8b);})['on'](_0xe06d('0x1e'),function(_0x318a94){logger[_0xe06d('0x1e')](_0x318a94);_0x42463d(_0x318a94);})[_0xe06d('0x21')]();});}function uploadFile(_0xca0991){return new BPromise(function(_0x28cceb,_0x329b5a){var _0x3af34c=urlParse(_0xca0991);var _0x4e9954=_0x3af34c[_0xe06d('0x13')]==='https:'?https:http;var _0x1237c6={'host':_0x3af34c[_0xe06d('0x15')],'path':_0x3af34c[_0xe06d('0x0')],'headers':{'user-agent':_0xe06d('0x16')}};_0x4e9954['get'](_0x1237c6,function(_0x8e3116){if(_0x8e3116['statusCode']!==0xc8){_0x329b5a(new Error('request\x20to\x20'+_0xca0991+_0xe06d('0x1a')+_0x8e3116['statusCode']+'\x20('+_0x8e3116[_0xe06d('0x1b')]+')'));return;}var _0x33f1e9='';_0x8e3116['on'](_0xe06d('0x22'),function(_0x3dc806){_0x33f1e9+=_0x3dc806;});_0x8e3116['on'](_0xe06d('0x21'),function(){_0x28cceb(_0x33f1e9);});})['on'](_0xe06d('0x1e'),function(_0x15bcae){_0x329b5a(_0x15bcae);})[_0xe06d('0x21')]();});}function convertFile(_0x50ad3c,_0x2b894e){return new BPromise(function(_0x3d626b,_0x27992f){var _0x1f7ba5=sox['transcode'](_0x50ad3c,_0x2b894e,{'sampleRate':0x1f40,'format':_0xe06d('0x23'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x1f7ba5['on'](_0xe06d('0x1e'),function(_0x30f87d){logger['error'](_0xe06d('0x24'),_0x30f87d);_0x27992f(_0x30f87d);});_0x1f7ba5['on'](_0xe06d('0x21'),function(){logger[_0xe06d('0x25')](_0xe06d('0x26'));_0x3d626b();});_0x1f7ba5[_0xe06d('0x27')]();});}function base64Decode(_0x3b7463,_0x9287fc){var _0x224478=path[_0xe06d('0x28')](__dirname,_0xe06d('0x29'),rs[_0xe06d('0x2a')](0x4)+_0xe06d('0x2b'));fs[_0xe06d('0x2c')](_0x224478,_0x3b7463,_0xe06d('0x2d'));return convertFile(_0x224478,_0x9287fc)['then'](function(){try{fs[_0xe06d('0x2e')](_0x224478);fs[_0xe06d('0x2f')](_0x9287fc,_0xe06d('0x30'));}catch(_0x8096e6){logger[_0xe06d('0x1e')](_0x8096e6);}return _0x9287fc[_0xe06d('0x31')]('.')[0x0];});}function base64Encode(_0x4913df){var _0x2323ca=fs[_0xe06d('0x32')](_0x4913df);return new Buffer(_0x2323ca)[_0xe06d('0x33')](_0xe06d('0x2d'));}exports[_0xe06d('0x34')]=function(_0x20c83f,_0x44e4f6,_0xd553b2,_0x379cc5,_0x433bfa,_0x54798a){var _0x49b5d2,_0x1d582d;var _0x1bdb2f=_0xe06d('0x35');var _0x1e280e=_0xe06d('0x36')+_0x20c83f;var _0x59e0f0={};if(_0x44e4f6===_0xe06d('0x37')){_0x59e0f0['input']={'ssml':_0xd553b2};}else{_0x59e0f0[_0xe06d('0x38')]={'text':_0xd553b2};};_0x59e0f0[_0xe06d('0x39')]={'languageCode':_0x379cc5,'ssmlGender':_0x433bfa};_0x59e0f0[_0xe06d('0x3a')]={'audioEncoding':_0xe06d('0x3b'),'sampleRateHertz':0x1f40};var _0xd42760={'url':_0x1bdb2f+'text:synthesize'+_0x1e280e,'method':_0xe06d('0x3c'),'json':!![],'body':_0x59e0f0};return rp(_0xd42760)[_0xe06d('0x3d')](function(_0x3d84cd){return new BPromise(function(_0xc9ce5d,_0x45ac4c){_0x49b5d2=path['resolve'](__dirname,_0xe06d('0x29'),rs['generate'](0x4)+'.mp3');var _0x2a66d3=Buffer[_0xe06d('0x3e')](_0x3d84cd[_0xe06d('0x3f')],_0xe06d('0x2d'));return fs[_0xe06d('0x40')](_0x49b5d2,_0x2a66d3,function(_0x303b2c){_0x45ac4c(_0x303b2c);},function(_0x5c2962){fs[_0xe06d('0x2f')](_0x49b5d2,_0xe06d('0x30'));_0xc9ce5d(_0x5c2962);});});})['then'](function(_0xcb0ba0){_0x1d582d=path['resolve'](__dirname,_0xe06d('0x29'),rs[_0xe06d('0x2a')](0x4)+_0xe06d('0x2b'));return convertFile(_0x49b5d2,_0x1d582d);})[_0xe06d('0x3d')](function(){try{fs[_0xe06d('0x2e')](_0x49b5d2);fs[_0xe06d('0x2f')](_0x1d582d,_0xe06d('0x30'));}catch(_0x584a42){logger[_0xe06d('0x1e')](_0x584a42);}logger['info']('googleCloudTTS\x20path',_0x1d582d[_0xe06d('0x31')]('.')[0x0]);return _0x1d582d[_0xe06d('0x31')]('.')[0x0];});};exports['googleTTS']=function(_0x415ca2,_0x35af8a){var _0x5d6350,_0xdd4d42;return tts(_0x415ca2,_0x35af8a||'en',0x1)[_0xe06d('0x3d')](function(_0x46ee28){logger['info'](_0x46ee28);_0x5d6350=path['resolve'](__dirname,_0xe06d('0x29'),rs[_0xe06d('0x2a')](0x4)+_0xe06d('0x41'));return downloadFile(_0x46ee28,_0x5d6350);})['then'](function(){_0xdd4d42=path[_0xe06d('0x28')](__dirname,'tmp',rs[_0xe06d('0x2a')](0x4)+_0xe06d('0x2b'));return convertFile(_0x5d6350,_0xdd4d42);})[_0xe06d('0x3d')](function(){try{fs['unlink'](_0x5d6350);fs['chmodSync'](_0xdd4d42,'777');}catch(_0x341fc5){logger[_0xe06d('0x1e')](_0x341fc5);}logger[_0xe06d('0x25')](_0xe06d('0x42'),_0xdd4d42[_0xe06d('0x31')]('.')[0x0]);return _0xdd4d42[_0xe06d('0x31')]('.')[0x0];});};exports['googleASR']=function(_0x58440f,_0x5e5035,_0x14e3d2){return google[_0xe06d('0x43')](_0x58440f,_0x5e5035,_0x14e3d2)[_0xe06d('0x3d')](function(_0x3c9bb6){logger[_0xe06d('0x25')](_0x3c9bb6['uri']);return rp(_0x3c9bb6);})[_0xe06d('0x3d')](function(_0x2c678f){var _0x5967b0='';var _0x2874ce=0x0;try{fs[_0xe06d('0x2e')](_0x58440f);}catch(_0x21f2aa){logger[_0xe06d('0x1e')](_0x21f2aa);}if(_0x2c678f&&_0x2c678f['results']){_0x5967b0=_0x2c678f[_0xe06d('0x44')][_0xe06d('0x45')](function(_0x2c8a97){return _0x2c8a97&&_0x2c8a97[_0xe06d('0x46')][0x0]&&_0x2c8a97[_0xe06d('0x46')][0x0][_0xe06d('0x47')]?_0x2c8a97['alternatives'][0x0][_0xe06d('0x47')]:'';})[_0xe06d('0x48')]('\x0a');_0x2874ce=_0x2c678f['results'][_0xe06d('0x45')](function(_0x28e68a){return _0x28e68a&&_0x28e68a['alternatives'][0x0]&&_0x28e68a[_0xe06d('0x46')][0x0][_0xe06d('0x49')]?_0x28e68a[_0xe06d('0x46')][0x0]['confidence']:0x0;})[_0xe06d('0x48')]('\x0a');}logger[_0xe06d('0x25')](_0xe06d('0x4a'),_0x5967b0);logger['info']('googleASR\x20confidence',_0x2874ce);return{'transcript':_0x5967b0,'confidence':_0x2874ce};})[_0xe06d('0x4b')](function(_0x28d834){logger[_0xe06d('0x1e')](_0xe06d('0x4c'),_0x28d834['statusCode'],_0x28d834[_0xe06d('0x4d')],_0x28d834['message']);});};exports[_0xe06d('0x4e')]=function(_0x278be6,_0x274341,_0x2488e4,_0x5c6f33){var _0x2711a0=apiai(_0x274341,{'language':_0x5c6f33||'en'});return _0x2711a0[_0xe06d('0x4f')](_0x2488e4,{'sessionId':md5(_0x278be6)})[_0xe06d('0x3d')](function(_0x529736){logger[_0xe06d('0x25')](JSON[_0xe06d('0x50')](_0x529736));return{'source':_0x529736[_0xe06d('0x51')][_0xe06d('0x52')],'resolvedQuery':_0x529736['result'][_0xe06d('0x53')],'action':_0x529736[_0xe06d('0x51')][_0xe06d('0x54')],'actionIncomplete':_0x529736[_0xe06d('0x51')][_0xe06d('0x55')],'speech':_0x529736[_0xe06d('0x51')]['fulfillment'][_0xe06d('0x56')],'score':_0x529736[_0xe06d('0x51')]['score'],'statusCode':_0x529736[_0xe06d('0x57')][_0xe06d('0x58')],'endConversation':_0x529736[_0xe06d('0x51')]['metadata']['endConversation']||![],'isFallbackIntent':_0x529736['result'][_0xe06d('0x59')]['isFallbackIntent']};});};exports[_0xe06d('0x5a')]=function(_0xed0fd5,_0x1dbf30,_0xc399fc,_0x4b86e3){return tilde['asr'](_0xed0fd5,_0x1dbf30,_0xc399fc,_0x4b86e3)[_0xe06d('0x3d')](function(_0x5aac65){try{fs[_0xe06d('0x2e')](_0xed0fd5);}catch(_0x5eca4d){logger[_0xe06d('0x1e')](_0x5eca4d);}logger[_0xe06d('0x25')](_0xe06d('0x5b'),_0x5aac65[_0xe06d('0x47')]);logger['info'](_0xe06d('0x5c'),_0x5aac65['confidence']);return _0x5aac65;});};exports[_0xe06d('0x5d')]=function(_0x39c6d4,_0x1ce29c,_0x561088,_0x49704b,_0x4632c2,_0xd4c6c0){var _0x52b8ef=path[_0xe06d('0x28')](__dirname,'tmp',rs['generate'](0x4)+_0xe06d('0x41'));var _0x9c3a1f;return aws[_0xe06d('0x5e')](_0x39c6d4,_0x1ce29c,_0x561088,_0x49704b,_0x4632c2,_0xd4c6c0,_0x52b8ef)[_0xe06d('0x3d')](function(){_0x9c3a1f=path[_0xe06d('0x28')](__dirname,_0xe06d('0x29'),rs['generate'](0x4)+'.wav');return convertFile(_0x52b8ef,_0x9c3a1f);})['then'](function(){try{fs[_0xe06d('0x2e')](_0x52b8ef);fs[_0xe06d('0x2f')](_0x9c3a1f,'777');}catch(_0x236214){logger[_0xe06d('0x1e')](_0x236214);}return _0x9c3a1f[_0xe06d('0x31')]('.')[0x0];});};exports[_0xe06d('0x5f')]=function(_0x5ca367,_0x40a095,_0x5733d0,_0x28266c,_0x1c3fdf,_0x70b865){return aws[_0xe06d('0x60')](_0x5ca367,_0x40a095,_0x5733d0,_0x28266c,_0x1c3fdf,_0x70b865)['then'](function(_0x4f0084){logger['info'](JSON[_0xe06d('0x50')](_0x4f0084));return _0x4f0084;});};exports['ispeechTTS']=function(_0x132445,_0x64ac1d,_0x27af69,_0x446f0b){var _0x45726e=util[_0xe06d('0x61')](_0xe06d('0x62'),ISPEECH_API,_0x132445,encodeURIComponent(_0x64ac1d),_0x27af69,_0x446f0b);var _0x5ec880=path[_0xe06d('0x28')](__dirname,_0xe06d('0x29'),rs['generate'](0x4)+_0xe06d('0x41'));var _0x5be31c;return downloadFile(_0x45726e,_0x5ec880)[_0xe06d('0x3d')](function(){_0x5be31c=path[_0xe06d('0x28')](__dirname,_0xe06d('0x29'),rs[_0xe06d('0x2a')](0x4)+_0xe06d('0x2b'));return convertFile(_0x5ec880,_0x5be31c);})[_0xe06d('0x3d')](function(){try{fs['unlink'](_0x5ec880);fs[_0xe06d('0x2f')](_0x5be31c,'777');}catch(_0x5952ce){logger[_0xe06d('0x1e')](_0x5952ce);}return _0x5be31c[_0xe06d('0x31')]('.')[0x0];});};exports[_0xe06d('0x63')]=function(_0x343288,_0x2fc73d,_0x198310,_0x3378d9){var _0xe411bc=util[_0xe06d('0x61')](_0xe06d('0x64'),ISPEECH_API,_0x2fc73d,_0x198310,base64Encode(_0x343288),_0x3378d9?util['format'](_0xe06d('0x65'),encodeURIComponent(_0x3378d9)):'freeform=3');return uploadFile(_0xe411bc)[_0xe06d('0x3d')](function(_0x504b12){return querystring[_0xe06d('0x66')](_0x504b12);});};exports[_0xe06d('0x67')]=function(_0x55b7ff,_0x2c26a4){return sestek[_0xe06d('0x68')](_0x55b7ff,_0x2c26a4)[_0xe06d('0x3d')](function(_0x496b3e){logger[_0xe06d('0x25')](JSON[_0xe06d('0x50')](_0x496b3e));var _0x20c1e4={'speech':_0x496b3e[_0xe06d('0x69')],'action':_0x496b3e[_0xe06d('0x6a')]?_0x496b3e[_0xe06d('0x6a')]['CustomAction']:undefined,'actiondata':_0x496b3e[_0xe06d('0x6a')]?_0x496b3e[_0xe06d('0x6a')]['CustomActionData']:undefined};if(_0x496b3e['channelData']&&_0x496b3e[_0xe06d('0x6a')][_0xe06d('0x6b')]){return base64Decode(_0x496b3e['channelData'][_0xe06d('0x6b')][_0xe06d('0x6c')],path[_0xe06d('0x28')](__dirname,_0xe06d('0x29'),rs['generate'](0x4)+_0xe06d('0x2b')))[_0xe06d('0x3d')](function(_0x524c21){_0x20c1e4[_0xe06d('0x6d')]=_0x524c21;return _0x20c1e4;});}return _0x20c1e4;});};exports[_0xe06d('0x6e')]=function(){return __dirname;};
\ No newline at end of file
+var _0x1fdc=['confidence','googleASR\x20transcription','googleASR\x20confidence','catch','[%s]\x20%s:%s','message','googleDialogflow','result','resolvedQuery','action','fulfillment','score','code','metadata','endConversation','isFallbackIntent','googleDialogflowV2','sessionPath','Dialogflow\x20V2\x20response:','queryResult','diagnosticInfo','fields','end_conversation','boolValue','intent','name','displayName','isFallback','languageCode','queryText','responseId','intentDetectionConfidence','fulfillmentText','tildeASR','Tilde\x20ASR\x20confidence','awsPolly','awsLex','lex','ispeechTTS','format','%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','model=%s','sestekNDA','nda','text','channelData','CustomAction','CustomActionData','AudioFromTts','Data','dirName','apiai-promise','bluebird','http','md5','path','querystring','randomstring','sox','google-tts-api','url','parse','util','./google','./sestek','./tilde','../../../config/logger','agi','https://api.ispeech.org/api/rest','protocol','https:','host','get','statusCode','error','request\x20to\x20','\x20failed,\x20status\x20code\x20=\x20','statusMessage','finish','info','close','unlink','download\x20error','pipe','end','transcode','wav','finish\x20to\x20convert','resolve','tmp','generate','.wav','writeFileSync','base64','then','split','readFileSync','toString','googleCloudTTS','https://texttospeech.googleapis.com/v1/','?key=','input','voice','text:synthesize','POST','777','chmodSync','googleCloudTTS\x20path','googleTTS','https://translate.google.com/_/TranslateWebserverUi/data/batchexecute','utf8','application/x-www-form-urlencoded','f.req=','stringify','jQ1olc','null','slice','parse\x20response\x20failed:\x0a','data','text\x20length\x20limit\x20reached','\x22\x20might\x20not\x20exist','.mp3','uri','results','map','alternatives','transcript','join'];(function(_0x405f4b,_0x25925c){var _0x6de134=function(_0x1caaa7){while(--_0x1caaa7){_0x405f4b['push'](_0x405f4b['shift']());}};_0x6de134(++_0x25925c);}(_0x1fdc,0xb5));var _0xc1fd=function(_0x5c4e16,_0x113035){_0x5c4e16=_0x5c4e16-0x0;var _0x36044a=_0x1fdc[_0x5c4e16];return _0x36044a;};'use strict';var apiai=require(_0xc1fd('0x0'));var BPromise=require(_0xc1fd('0x1'));var dialogflow=require('dialogflow');var fs=require('fs');var http=require(_0xc1fd('0x2'));var https=require('https');var md5=require(_0xc1fd('0x3'));var path=require(_0xc1fd('0x4'));var querystring=require(_0xc1fd('0x5'));var rp=require('request-promise');var rs=require(_0xc1fd('0x6'));var sox=require(_0xc1fd('0x7'));var tts=require(_0xc1fd('0x8'));var urlParse=require(_0xc1fd('0x9'))[_0xc1fd('0xa')];var util=require(_0xc1fd('0xb'));var aws=require('./aws');var google=require(_0xc1fd('0xc'));var sestek=require(_0xc1fd('0xd'));var tilde=require(_0xc1fd('0xe'));var logger=require(_0xc1fd('0xf'))(_0xc1fd('0x10'));var ISPEECH_API=_0xc1fd('0x11');function downloadFile(_0x51b432,_0x15039e){return new BPromise(function(_0x2de750,_0x4134d9){var _0x52faed=urlParse(_0x51b432);var _0x42d368=_0x52faed[_0xc1fd('0x12')]===_0xc1fd('0x13')?https:http;var _0x4dd0e1={'host':_0x52faed[_0xc1fd('0x14')],'path':_0x52faed[_0xc1fd('0x4')],'headers':{'user-agent':'WHAT_EVER'}};_0x42d368[_0xc1fd('0x15')](_0x4dd0e1,function(_0x4f5e16){if(_0x4f5e16[_0xc1fd('0x16')]!==0xc8){logger[_0xc1fd('0x17')](_0xc1fd('0x18')+_0x51b432+_0xc1fd('0x19')+_0x4f5e16[_0xc1fd('0x16')]+'\x20('+_0x4f5e16['statusMessage']+')');_0x4134d9(new Error('request\x20to\x20'+_0x51b432+_0xc1fd('0x19')+_0x4f5e16[_0xc1fd('0x16')]+'\x20('+_0x4f5e16[_0xc1fd('0x1a')]+')'));return;}var _0x17bf16=fs['createWriteStream'](_0x15039e);_0x17bf16['on'](_0xc1fd('0x1b'),function(){logger[_0xc1fd('0x1c')]('finish\x20download\x20file');_0x17bf16[_0xc1fd('0x1d')](_0x2de750);});_0x17bf16['on'](_0xc1fd('0x17'),function(_0x23f622){fs[_0xc1fd('0x1e')](_0x15039e);logger['error'](_0xc1fd('0x1f'),_0x23f622);_0x4134d9(_0x23f622);});_0x4f5e16[_0xc1fd('0x20')](_0x17bf16);})['on'](_0xc1fd('0x17'),function(_0x495a93){logger[_0xc1fd('0x17')](_0x495a93);_0x4134d9(_0x495a93);})[_0xc1fd('0x21')]();});}function uploadFile(_0x10f63e){return new BPromise(function(_0x34291c,_0x31d731){var _0x53f907=urlParse(_0x10f63e);var _0x400a4=_0x53f907[_0xc1fd('0x12')]==='https:'?https:http;var _0x288fdc={'host':_0x53f907[_0xc1fd('0x14')],'path':_0x53f907[_0xc1fd('0x4')],'headers':{'user-agent':'WHAT_EVER'}};_0x400a4['get'](_0x288fdc,function(_0x5b6bdd){if(_0x5b6bdd[_0xc1fd('0x16')]!==0xc8){_0x31d731(new Error(_0xc1fd('0x18')+_0x10f63e+_0xc1fd('0x19')+_0x5b6bdd['statusCode']+'\x20('+_0x5b6bdd['statusMessage']+')'));return;}var _0x307a21='';_0x5b6bdd['on']('data',function(_0x2674ea){_0x307a21+=_0x2674ea;});_0x5b6bdd['on'](_0xc1fd('0x21'),function(){_0x34291c(_0x307a21);});})['on'](_0xc1fd('0x17'),function(_0x5a615d){_0x31d731(_0x5a615d);})['end']();});}function convertFile(_0x44f683,_0x8eee6){return new BPromise(function(_0x139a89,_0x15e58a){var _0x357758=sox[_0xc1fd('0x22')](_0x44f683,_0x8eee6,{'sampleRate':0x1f40,'format':_0xc1fd('0x23'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x357758['on'](_0xc1fd('0x17'),function(_0x2072e4){logger['error']('error\x20convert',_0x2072e4);_0x15e58a(_0x2072e4);});_0x357758['on'](_0xc1fd('0x21'),function(){logger['info'](_0xc1fd('0x24'));_0x139a89();});_0x357758['start']();});}function base64Decode(_0x2f7447,_0x3d0eaf){var _0x183ecf=path[_0xc1fd('0x25')](__dirname,_0xc1fd('0x26'),rs[_0xc1fd('0x27')](0x4)+_0xc1fd('0x28'));fs[_0xc1fd('0x29')](_0x183ecf,_0x2f7447,_0xc1fd('0x2a'));return convertFile(_0x183ecf,_0x3d0eaf)[_0xc1fd('0x2b')](function(){try{fs[_0xc1fd('0x1e')](_0x183ecf);fs['chmodSync'](_0x3d0eaf,'777');}catch(_0x50a106){logger[_0xc1fd('0x17')](_0x50a106);}return _0x3d0eaf[_0xc1fd('0x2c')]('.')[0x0];});}function base64Encode(_0x445d15){var _0x2fb3ac=fs[_0xc1fd('0x2d')](_0x445d15);return new Buffer(_0x2fb3ac)[_0xc1fd('0x2e')](_0xc1fd('0x2a'));}exports[_0xc1fd('0x2f')]=function(_0x3ad175,_0x213f3,_0x1d8b34,_0x41a425,_0xe6a080,_0x227d42){var _0x17e653,_0x403bf5;var _0x57af43=_0xc1fd('0x30');var _0x45ef76=_0xc1fd('0x31')+_0x3ad175;var _0x4a1b16={};if(_0x213f3==='ssml'){_0x4a1b16[_0xc1fd('0x32')]={'ssml':_0x1d8b34};}else{_0x4a1b16[_0xc1fd('0x32')]={'text':_0x1d8b34};};_0x4a1b16[_0xc1fd('0x33')]={'languageCode':_0x41a425,'ssmlGender':_0xe6a080};_0x4a1b16['audioConfig']={'audioEncoding':'MP3','sampleRateHertz':0x1f40};var _0x2a63da={'url':_0x57af43+_0xc1fd('0x34')+_0x45ef76,'method':_0xc1fd('0x35'),'json':!![],'body':_0x4a1b16};return rp(_0x2a63da)[_0xc1fd('0x2b')](function(_0x18c01a){return new BPromise(function(_0x233155,_0x3a6a5e){_0x17e653=path[_0xc1fd('0x25')](__dirname,_0xc1fd('0x26'),rs[_0xc1fd('0x27')](0x4)+'.mp3');var _0xd25961=Buffer['from'](_0x18c01a['audioContent'],_0xc1fd('0x2a'));return fs['writeFile'](_0x17e653,_0xd25961,function(_0x4a3e05){_0x3a6a5e(_0x4a3e05);},function(_0x1d8b55){fs['chmodSync'](_0x17e653,_0xc1fd('0x36'));_0x233155(_0x1d8b55);});});})[_0xc1fd('0x2b')](function(_0x248a6f){_0x403bf5=path[_0xc1fd('0x25')](__dirname,_0xc1fd('0x26'),rs['generate'](0x4)+'.wav');return convertFile(_0x17e653,_0x403bf5);})['then'](function(){try{fs[_0xc1fd('0x1e')](_0x17e653);fs[_0xc1fd('0x37')](_0x403bf5,_0xc1fd('0x36'));}catch(_0x444cb7){logger[_0xc1fd('0x17')](_0x444cb7);}logger[_0xc1fd('0x1c')](_0xc1fd('0x38'),_0x403bf5['split']('.')[0x0]);return _0x403bf5[_0xc1fd('0x2c')]('.')[0x0];});};exports[_0xc1fd('0x39')]=function(_0xc58f21,_0x36b1ee){var _0x19b650=_0xc1fd('0x3a');var _0x436129,_0x39b3c7;var _0x18fb9c;var _0x508c81={'encoding':_0xc1fd('0x3b'),'method':_0xc1fd('0x35'),'timeout':0x2710,'url':_0x19b650,'headers':{'Content-Type':_0xc1fd('0x3c')},'body':_0xc1fd('0x3d')+encodeURIComponent(JSON[_0xc1fd('0x3e')]([[[_0xc1fd('0x3f'),JSON[_0xc1fd('0x3e')]([_0xc58f21,_0x36b1ee||'en',![],_0xc1fd('0x40')]),null,'generic']]]))};return rp(_0x508c81)[_0xc1fd('0x2b')](function(_0x152963){try{_0x18fb9c=eval(_0x152963[_0xc1fd('0x41')](0x5))[0x0][0x2];}catch(_0x51c757){throw new Error(_0xc1fd('0x42')+_0x152963[_0xc1fd('0x43')]);}if(!_0x18fb9c){if(_0xc58f21['length']>0xc8){throw new Error(_0xc1fd('0x44'));}else{throw new Error('lang\x20\x22'+_0x36b1ee+_0xc1fd('0x45'));}}try{_0x18fb9c=eval(_0x18fb9c)[0x0];}catch(_0x58fb1d){throw new Error(_0xc1fd('0x42')+res[_0xc1fd('0x43')]);}const _0x43226b=_0x18fb9c;_0x436129=path[_0xc1fd('0x25')](__dirname,_0xc1fd('0x26'),rs[_0xc1fd('0x27')](0x4)+_0xc1fd('0x46'));fs[_0xc1fd('0x29')](_0x436129,_0x18fb9c,{'encoding':_0xc1fd('0x2a')});_0x39b3c7=path['resolve'](__dirname,_0xc1fd('0x26'),rs[_0xc1fd('0x27')](0x4)+'.wav');return convertFile(_0x436129,_0x39b3c7);})[_0xc1fd('0x2b')](function(){try{fs[_0xc1fd('0x1e')](_0x436129);fs[_0xc1fd('0x37')](_0x39b3c7,_0xc1fd('0x36'));}catch(_0x538d7a){logger[_0xc1fd('0x17')](_0x538d7a);}logger[_0xc1fd('0x1c')]('goggleTTS\x20path',_0x39b3c7[_0xc1fd('0x2c')]('.')[0x0]);return _0x39b3c7[_0xc1fd('0x2c')]('.')[0x0];});};exports['googleASR']=function(_0x4ac983,_0x5c1ecd,_0x32682c){return google['asr'](_0x4ac983,_0x5c1ecd,_0x32682c)[_0xc1fd('0x2b')](function(_0x1e9564){logger[_0xc1fd('0x1c')](_0x1e9564[_0xc1fd('0x47')]);return rp(_0x1e9564);})[_0xc1fd('0x2b')](function(_0x2b2bfd){var _0x3a1b78='';var _0x26f387=0x0;try{fs[_0xc1fd('0x1e')](_0x4ac983);}catch(_0x2b1f5e){logger[_0xc1fd('0x17')](_0x2b1f5e);}if(_0x2b2bfd&&_0x2b2bfd['results']){_0x3a1b78=_0x2b2bfd[_0xc1fd('0x48')][_0xc1fd('0x49')](function(_0x488323){return _0x488323&&_0x488323[_0xc1fd('0x4a')][0x0]&&_0x488323[_0xc1fd('0x4a')][0x0][_0xc1fd('0x4b')]?_0x488323[_0xc1fd('0x4a')][0x0]['transcript']:'';})[_0xc1fd('0x4c')]('\x0a');_0x26f387=_0x2b2bfd[_0xc1fd('0x48')][_0xc1fd('0x49')](function(_0x4734f1){return _0x4734f1&&_0x4734f1[_0xc1fd('0x4a')][0x0]&&_0x4734f1[_0xc1fd('0x4a')][0x0]['confidence']?_0x4734f1[_0xc1fd('0x4a')][0x0][_0xc1fd('0x4d')]:0x0;})[_0xc1fd('0x4c')]('\x0a');}logger['info'](_0xc1fd('0x4e'),_0x3a1b78);logger[_0xc1fd('0x1c')](_0xc1fd('0x4f'),_0x26f387);return{'transcript':_0x3a1b78,'confidence':_0x26f387};})[_0xc1fd('0x50')](function(_0x1b9c68){logger['error'](_0xc1fd('0x51'),_0x1b9c68[_0xc1fd('0x16')],_0x1b9c68['name'],_0x1b9c68[_0xc1fd('0x52')]);});};exports[_0xc1fd('0x53')]=function(_0x1b19d3,_0x53dcb0,_0x47bf44,_0x79225b){var _0x2921c3=apiai(_0x53dcb0,{'language':_0x79225b||'en'});return _0x2921c3['textRequest'](_0x47bf44,{'sessionId':md5(_0x1b19d3)})[_0xc1fd('0x2b')](function(_0x20d08d){logger[_0xc1fd('0x1c')](JSON[_0xc1fd('0x3e')](_0x20d08d));return{'source':_0x20d08d[_0xc1fd('0x54')]['source'],'resolvedQuery':_0x20d08d['result'][_0xc1fd('0x55')],'action':_0x20d08d['result'][_0xc1fd('0x56')],'actionIncomplete':_0x20d08d[_0xc1fd('0x54')]['actionIncomplete'],'speech':_0x20d08d[_0xc1fd('0x54')][_0xc1fd('0x57')]['speech'],'score':_0x20d08d['result'][_0xc1fd('0x58')],'statusCode':_0x20d08d['status'][_0xc1fd('0x59')],'endConversation':_0x20d08d[_0xc1fd('0x54')][_0xc1fd('0x5a')][_0xc1fd('0x5b')]||![],'isFallbackIntent':_0x20d08d[_0xc1fd('0x54')][_0xc1fd('0x5a')][_0xc1fd('0x5c')]};});};exports[_0xc1fd('0x5d')]=function(_0x3d18a5,_0x19b777,_0x4a2402,_0x2bea56,_0x5e4d33,_0x2a8322){var _0x2e9909=_0x2bea56['replace'](/\\n/g,'\x0a');var _0x43324f={'credentials':{'private_key':_0x2e9909,'client_email':_0x4a2402}};var _0x123d6b=new dialogflow['SessionsClient'](_0x43324f);var _0x377058=_0x123d6b[_0xc1fd('0x5e')](_0x19b777,md5(_0x3d18a5));var _0x13fece={'session':_0x377058,'queryInput':{'text':{'text':_0x5e4d33,'languageCode':_0x2a8322}}};return _0x123d6b['detectIntent'](_0x13fece)['then'](function(_0x43c518){if(_0x43c518&&_0x43c518['length']){logger[_0xc1fd('0x1c')](_0xc1fd('0x5f'),JSON['stringify'](_0x43c518));var _0x1090ba=_0x43c518[0x0];if(_0x1090ba){var _0x47db4b={'action':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x56')],'allRequiredParamsPresent':_0x1090ba[_0xc1fd('0x60')]['allRequiredParamsPresent'],'endConversation':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x61')]&&_0x1090ba['queryResult'][_0xc1fd('0x61')][_0xc1fd('0x62')]?_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x61')][_0xc1fd('0x62')][_0xc1fd('0x63')][_0xc1fd('0x64')]:![],'fulfillmentText':_0x1090ba[_0xc1fd('0x60')]['fulfillmentText'],'intentName':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x65')][_0xc1fd('0x66')],'intentDisplayName':_0x1090ba[_0xc1fd('0x60')]['intent'][_0xc1fd('0x67')],'isFallbackIntent':_0x1090ba['queryResult'][_0xc1fd('0x65')][_0xc1fd('0x68')],'languageCode':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x69')],'queryText':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x6a')],'responseId':_0x1090ba[_0xc1fd('0x6b')],'score':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x6c')],'speech':_0x1090ba[_0xc1fd('0x60')][_0xc1fd('0x6d')],'providerResponse':JSON['stringify'](_0x43c518)};return _0x47db4b;}}});};exports[_0xc1fd('0x6e')]=function(_0x1a899d,_0x1d54de,_0x26461d,_0xc6ce24){return tilde['asr'](_0x1a899d,_0x1d54de,_0x26461d,_0xc6ce24)[_0xc1fd('0x2b')](function(_0x5d5b78){try{fs[_0xc1fd('0x1e')](_0x1a899d);}catch(_0x4f8b4a){logger['error'](_0x4f8b4a);}logger['info']('Tilde\x20ASR\x20transcription',_0x5d5b78[_0xc1fd('0x4b')]);logger[_0xc1fd('0x1c')](_0xc1fd('0x6f'),_0x5d5b78['confidence']);return _0x5d5b78;});};exports[_0xc1fd('0x70')]=function(_0x14bb30,_0x4d533c,_0x21e259,_0x5292fa,_0x39dd50,_0xe22236){var _0x1bcb24=path[_0xc1fd('0x25')](__dirname,'tmp',rs[_0xc1fd('0x27')](0x4)+_0xc1fd('0x46'));var _0x427c9b;return aws['polly'](_0x14bb30,_0x4d533c,_0x21e259,_0x5292fa,_0x39dd50,_0xe22236,_0x1bcb24)[_0xc1fd('0x2b')](function(){_0x427c9b=path['resolve'](__dirname,'tmp',rs['generate'](0x4)+_0xc1fd('0x28'));return convertFile(_0x1bcb24,_0x427c9b);})[_0xc1fd('0x2b')](function(){try{fs[_0xc1fd('0x1e')](_0x1bcb24);fs['chmodSync'](_0x427c9b,'777');}catch(_0x411acc){logger[_0xc1fd('0x17')](_0x411acc);}return _0x427c9b[_0xc1fd('0x2c')]('.')[0x0];});};exports[_0xc1fd('0x71')]=function(_0x1348a4,_0x5169e8,_0x423cb4,_0x5cf1bd,_0x407db0,_0x29efae){return aws[_0xc1fd('0x72')](_0x1348a4,_0x5169e8,_0x423cb4,_0x5cf1bd,_0x407db0,_0x29efae)[_0xc1fd('0x2b')](function(_0x534a24){logger[_0xc1fd('0x1c')](JSON[_0xc1fd('0x3e')](_0x534a24));return _0x534a24;});};exports[_0xc1fd('0x73')]=function(_0x28dcf0,_0x25771e,_0x257ce2,_0xcd4c48){var _0x2d85c8=util[_0xc1fd('0x74')](_0xc1fd('0x75'),ISPEECH_API,_0x28dcf0,encodeURIComponent(_0x25771e),_0x257ce2,_0xcd4c48);var _0x4547e6=path[_0xc1fd('0x25')](__dirname,_0xc1fd('0x26'),rs[_0xc1fd('0x27')](0x4)+'.mp3');var _0x4acecb;return downloadFile(_0x2d85c8,_0x4547e6)['then'](function(){_0x4acecb=path[_0xc1fd('0x25')](__dirname,_0xc1fd('0x26'),rs[_0xc1fd('0x27')](0x4)+_0xc1fd('0x28'));return convertFile(_0x4547e6,_0x4acecb);})[_0xc1fd('0x2b')](function(){try{fs[_0xc1fd('0x1e')](_0x4547e6);fs['chmodSync'](_0x4acecb,'777');}catch(_0x33a29f){logger[_0xc1fd('0x17')](_0x33a29f);}return _0x4acecb['split']('.')[0x0];});};exports['ispeechASR']=function(_0x111093,_0x111cbb,_0x59ef1d,_0x44e52d){var _0x32ea6b=util[_0xc1fd('0x74')](_0xc1fd('0x76'),ISPEECH_API,_0x111cbb,_0x59ef1d,base64Encode(_0x111093),_0x44e52d?util[_0xc1fd('0x74')](_0xc1fd('0x77'),encodeURIComponent(_0x44e52d)):'freeform=3');return uploadFile(_0x32ea6b)[_0xc1fd('0x2b')](function(_0x384bf2){return querystring[_0xc1fd('0xa')](_0x384bf2);});};exports[_0xc1fd('0x78')]=function(_0x4ca271,_0x5c108f){return sestek[_0xc1fd('0x79')](_0x4ca271,_0x5c108f)[_0xc1fd('0x2b')](function(_0xa1e83d){logger['info'](JSON[_0xc1fd('0x3e')](_0xa1e83d));var _0x2e18c2={'speech':_0xa1e83d[_0xc1fd('0x7a')],'action':_0xa1e83d[_0xc1fd('0x7b')]?_0xa1e83d[_0xc1fd('0x7b')][_0xc1fd('0x7c')]:undefined,'actiondata':_0xa1e83d[_0xc1fd('0x7b')]?_0xa1e83d[_0xc1fd('0x7b')][_0xc1fd('0x7d')]:undefined};if(_0xa1e83d['channelData']&&_0xa1e83d[_0xc1fd('0x7b')][_0xc1fd('0x7e')]){return base64Decode(_0xa1e83d['channelData']['AudioFromTts'][_0xc1fd('0x7f')],path['resolve'](__dirname,'tmp',rs[_0xc1fd('0x27')](0x4)+'.wav'))[_0xc1fd('0x2b')](function(_0x2c8aa2){_0x2e18c2['audiofile']=_0x2c8aa2;return _0x2e18c2;});}return _0x2e18c2;});};exports[_0xc1fd('0x80')]=function(){return __dirname;};
\ No newline at end of file