18 var _0x8295=['.wav','googleCloudTTS\x20path','https://translate.google.com/_/TranslateWebserverUi/data/batchexecute','utf8','stringify','null','generic','parse\x20response\x20failed:\x0a','text\x20length\x20limit\x20reached','lang\x20\x22','\x22\x20might\x20not\x20exist','writeFileSync','goggleTTS\x20path','googleASR','asr','uri','results','alternatives','transcript','map','confidence','googleASR\x20transcription','googleASR\x20confidence','catch','[%s]\x20%s:%s','name','textRequest','result','source','action','actionIncomplete','fulfillment','speech','score','status','code','metadata','isFallbackIntent','replace','SessionsClient','sessionPath','Dialogflow\x20V2\x20response:','queryResult','allRequiredParamsPresent','diagnosticInfo','fields','end_conversation','boolValue','fulfillmentText','intent','displayName','languageCode','queryText','Tilde\x20ASR\x20transcription','Tilde\x20ASR\x20confidence','awsPolly','polly','lex','ispeechTTS','%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3','ispeechASR','format','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','model=%s','freeform=3','parse','nda','text','channelData','CustomAction','AudioFromTts','Data','audiofile','dirName','bluebird','dialogflow','http','https','md5','path','request-promise','randomstring','sox','url','util','./aws','./google','./sestek','./tilde','../../../config/logger','https://api.ispeech.org/api/rest','protocol','https:','get','error','request\x20to\x20','\x20failed,\x20status\x20code\x20=\x20','statusCode','statusMessage','createWriteStream','info','finish\x20download\x20file','unlink','download\x20error','end','host','WHAT_EVER','data','transcode','wav','error\x20convert','start','resolve','generate','base64','then','chmodSync','777','split','readFileSync','toString','https://texttospeech.googleapis.com/v1/','?key=','ssml','input','voice','audioConfig','MP3','text:synthesize','tmp','.mp3','from','audioContent','writeFile'];(function(_0x17521d,_0x5ee0ba){var _0x283d4f=function(_0x4fdad5){while(--_0x4fdad5){_0x17521d['push'](_0x17521d['shift']());}};_0x283d4f(++_0x5ee0ba);}(_0x8295,0xd0));var _0x5829=function(_0x565c49,_0x54acd0){_0x565c49=_0x565c49-0x0;var _0x20ca34=_0x8295[_0x565c49];return _0x20ca34;};'use strict';var apiai=require('apiai-promise');var BPromise=require(_0x5829('0x0'));var dialogflow=require(_0x5829('0x1'));var fs=require('fs');var http=require(_0x5829('0x2'));var https=require(_0x5829('0x3'));var md5=require(_0x5829('0x4'));var path=require(_0x5829('0x5'));var querystring=require('querystring');var rp=require(_0x5829('0x6'));var rs=require(_0x5829('0x7'));var sox=require(_0x5829('0x8'));var tts=require('google-tts-api');var urlParse=require(_0x5829('0x9'))['parse'];var util=require(_0x5829('0xa'));var aws=require(_0x5829('0xb'));var google=require(_0x5829('0xc'));var sestek=require(_0x5829('0xd'));var tilde=require(_0x5829('0xe'));var logger=require(_0x5829('0xf'))('agi');var ISPEECH_API=_0x5829('0x10');function downloadFile(_0x3f3d5f,_0x4e35e6){return new BPromise(function(_0x153bb8,_0x52a335){var _0x11500e=urlParse(_0x3f3d5f);var _0x4cbe04=_0x11500e[_0x5829('0x11')]===_0x5829('0x12')?https:http;var _0x1d525a={'host':_0x11500e['host'],'path':_0x11500e[_0x5829('0x5')],'headers':{'user-agent':'WHAT_EVER'}};_0x4cbe04[_0x5829('0x13')](_0x1d525a,function(_0x5303ee){if(_0x5303ee['statusCode']!==0xc8){logger[_0x5829('0x14')](_0x5829('0x15')+_0x3f3d5f+_0x5829('0x16')+_0x5303ee[_0x5829('0x17')]+'\x20('+_0x5303ee[_0x5829('0x18')]+')');_0x52a335(new Error(_0x5829('0x15')+_0x3f3d5f+'\x20failed,\x20status\x20code\x20=\x20'+_0x5303ee['statusCode']+'\x20('+_0x5303ee[_0x5829('0x18')]+')'));return;}var _0x93fba7=fs[_0x5829('0x19')](_0x4e35e6);_0x93fba7['on']('finish',function(){logger[_0x5829('0x1a')](_0x5829('0x1b'));_0x93fba7['close'](_0x153bb8);});_0x93fba7['on']('error',function(_0x1f26ef){fs[_0x5829('0x1c')](_0x4e35e6);logger[_0x5829('0x14')](_0x5829('0x1d'),_0x1f26ef);_0x52a335(_0x1f26ef);});_0x5303ee['pipe'](_0x93fba7);})['on'](_0x5829('0x14'),function(_0x3bca2b){logger[_0x5829('0x14')](_0x3bca2b);_0x52a335(_0x3bca2b);})[_0x5829('0x1e')]();});}function uploadFile(_0x49a42b){return new BPromise(function(_0x373b6b,_0x471512){var _0x1a7941=urlParse(_0x49a42b);var _0x56fc59=_0x1a7941[_0x5829('0x11')]===_0x5829('0x12')?https:http;var _0xe84845={'host':_0x1a7941[_0x5829('0x1f')],'path':_0x1a7941[_0x5829('0x5')],'headers':{'user-agent':_0x5829('0x20')}};_0x56fc59[_0x5829('0x13')](_0xe84845,function(_0x44fc61){if(_0x44fc61[_0x5829('0x17')]!==0xc8){_0x471512(new Error('request\x20to\x20'+_0x49a42b+_0x5829('0x16')+_0x44fc61['statusCode']+'\x20('+_0x44fc61[_0x5829('0x18')]+')'));return;}var _0x4e9145='';_0x44fc61['on'](_0x5829('0x21'),function(_0x19132a){_0x4e9145+=_0x19132a;});_0x44fc61['on']('end',function(){_0x373b6b(_0x4e9145);});})['on'](_0x5829('0x14'),function(_0x427aa2){_0x471512(_0x427aa2);})[_0x5829('0x1e')]();});}function convertFile(_0x45b76e,_0x3c8a53){return new BPromise(function(_0x2bd4ce,_0x3c5f3f){var _0x2667b1=sox[_0x5829('0x22')](_0x45b76e,_0x3c8a53,{'sampleRate':0x1f40,'format':_0x5829('0x23'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x2667b1['on'](_0x5829('0x14'),function(_0x192628){logger[_0x5829('0x14')](_0x5829('0x24'),_0x192628);_0x3c5f3f(_0x192628);});_0x2667b1['on'](_0x5829('0x1e'),function(){logger[_0x5829('0x1a')]('finish\x20to\x20convert');_0x2bd4ce();});_0x2667b1[_0x5829('0x25')]();});}function base64Decode(_0x2336ef,_0x5338b0){var _0x536ed2=path[_0x5829('0x26')](__dirname,'tmp',rs[_0x5829('0x27')](0x4)+'.wav');fs['writeFileSync'](_0x536ed2,_0x2336ef,_0x5829('0x28'));return convertFile(_0x536ed2,_0x5338b0)[_0x5829('0x29')](function(){try{fs[_0x5829('0x1c')](_0x536ed2);fs[_0x5829('0x2a')](_0x5338b0,_0x5829('0x2b'));}catch(_0x417640){logger['error'](_0x417640);}return _0x5338b0[_0x5829('0x2c')]('.')[0x0];});}function base64Encode(_0x30c01b){var _0xb663bf=fs[_0x5829('0x2d')](_0x30c01b);return new Buffer(_0xb663bf)[_0x5829('0x2e')](_0x5829('0x28'));}exports['googleCloudTTS']=function(_0x11e92f,_0x4256db,_0x5b057a,_0x52fb96,_0x2838df,_0x542bc5){var _0x54f6d3,_0x409ad3;var _0x3d3a0d=_0x5829('0x2f');var _0x2fdb52=_0x5829('0x30')+_0x11e92f;var _0x34542d={};if(_0x4256db===_0x5829('0x31')){_0x34542d['input']={'ssml':_0x5b057a};}else{_0x34542d[_0x5829('0x32')]={'text':_0x5b057a};};_0x34542d[_0x5829('0x33')]={'languageCode':_0x52fb96,'ssmlGender':_0x2838df};_0x34542d[_0x5829('0x34')]={'audioEncoding':_0x5829('0x35'),'sampleRateHertz':0x1f40};var _0xfec57b={'url':_0x3d3a0d+_0x5829('0x36')+_0x2fdb52,'method':'POST','json':!![],'body':_0x34542d};return rp(_0xfec57b)[_0x5829('0x29')](function(_0x129dec){return new BPromise(function(_0x4dc24f,_0x9ef7f5){_0x54f6d3=path['resolve'](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+_0x5829('0x38'));var _0x211a4a=Buffer[_0x5829('0x39')](_0x129dec[_0x5829('0x3a')],'base64');return fs[_0x5829('0x3b')](_0x54f6d3,_0x211a4a,function(_0x1c9b8f){_0x9ef7f5(_0x1c9b8f);},function(_0x3f88ea){fs['chmodSync'](_0x54f6d3,_0x5829('0x2b'));_0x4dc24f(_0x3f88ea);});});})[_0x5829('0x29')](function(_0x23a030){_0x409ad3=path['resolve'](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+_0x5829('0x3c'));return convertFile(_0x54f6d3,_0x409ad3);})[_0x5829('0x29')](function(){try{fs['unlink'](_0x54f6d3);fs['chmodSync'](_0x409ad3,'777');}catch(_0x2a8e53){logger['error'](_0x2a8e53);}logger['info'](_0x5829('0x3d'),_0x409ad3[_0x5829('0x2c')]('.')[0x0]);return _0x409ad3['split']('.')[0x0];});};exports['googleTTS']=function(_0x597036,_0x2f106f){var _0x2f68da=_0x5829('0x3e');var _0x103722,_0x43f06e;var _0x193de6;var _0x5ab0ff={'encoding':_0x5829('0x3f'),'method':'POST','timeout':0x2710,'url':_0x2f68da,'headers':{'Content-Type':'application/x-www-form-urlencoded'},'body':'f.req='+encodeURIComponent(JSON[_0x5829('0x40')]([[['jQ1olc',JSON[_0x5829('0x40')]([_0x597036,_0x2f106f||'en',![],_0x5829('0x41')]),null,_0x5829('0x42')]]]))};return rp(_0x5ab0ff)['then'](function(_0x1b08f5){try{_0x193de6=eval(_0x1b08f5['slice'](0x5))[0x0][0x2];}catch(_0x3bc38b){throw new Error(_0x5829('0x43')+_0x1b08f5[_0x5829('0x21')]);}if(!_0x193de6){if(_0x597036['length']>0xc8){throw new Error(_0x5829('0x44'));}else{throw new Error(_0x5829('0x45')+_0x2f106f+_0x5829('0x46'));}}try{_0x193de6=eval(_0x193de6)[0x0];}catch(_0x509043){throw new Error('parse\x20response\x20failed:\x0a'+res[_0x5829('0x21')]);}const _0x5c04b6=_0x193de6;_0x103722=path[_0x5829('0x26')](__dirname,_0x5829('0x37'),rs['generate'](0x4)+_0x5829('0x38'));fs[_0x5829('0x47')](_0x103722,_0x193de6,{'encoding':_0x5829('0x28')});_0x43f06e=path[_0x5829('0x26')](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+_0x5829('0x3c'));return convertFile(_0x103722,_0x43f06e);})['then'](function(){try{fs[_0x5829('0x1c')](_0x103722);fs['chmodSync'](_0x43f06e,'777');}catch(_0xa5a872){logger['error'](_0xa5a872);}logger['info'](_0x5829('0x48'),_0x43f06e[_0x5829('0x2c')]('.')[0x0]);return _0x43f06e[_0x5829('0x2c')]('.')[0x0];});};exports[_0x5829('0x49')]=function(_0x2e6b1d,_0x53d48a,_0x49766e){return google[_0x5829('0x4a')](_0x2e6b1d,_0x53d48a,_0x49766e)['then'](function(_0x50b24c){logger[_0x5829('0x1a')](_0x50b24c[_0x5829('0x4b')]);return rp(_0x50b24c);})['then'](function(_0x54f922){var _0x1d4573='';var _0x57a6d5=0x0;try{fs[_0x5829('0x1c')](_0x2e6b1d);}catch(_0x309d8f){logger[_0x5829('0x14')](_0x309d8f);}if(_0x54f922&&_0x54f922[_0x5829('0x4c')]){_0x1d4573=_0x54f922['results']['map'](function(_0x328c07){return _0x328c07&&_0x328c07[_0x5829('0x4d')][0x0]&&_0x328c07[_0x5829('0x4d')][0x0][_0x5829('0x4e')]?_0x328c07[_0x5829('0x4d')][0x0][_0x5829('0x4e')]:'';})['join']('\x0a');_0x57a6d5=_0x54f922[_0x5829('0x4c')][_0x5829('0x4f')](function(_0x4b1d7e){return _0x4b1d7e&&_0x4b1d7e[_0x5829('0x4d')][0x0]&&_0x4b1d7e[_0x5829('0x4d')][0x0][_0x5829('0x50')]?_0x4b1d7e['alternatives'][0x0][_0x5829('0x50')]:0x0;})['join']('\x0a');}logger[_0x5829('0x1a')](_0x5829('0x51'),_0x1d4573);logger[_0x5829('0x1a')](_0x5829('0x52'),_0x57a6d5);return{'transcript':_0x1d4573,'confidence':_0x57a6d5};})[_0x5829('0x53')](function(_0x304ff1){logger[_0x5829('0x14')](_0x5829('0x54'),_0x304ff1[_0x5829('0x17')],_0x304ff1[_0x5829('0x55')],_0x304ff1['message']);});};exports['googleDialogflow']=function(_0x1cf8fd,_0x4c5aaa,_0xb82299,_0x38d6a6){var _0x159b28=apiai(_0x4c5aaa,{'language':_0x38d6a6||'en'});return _0x159b28[_0x5829('0x56')](_0xb82299,{'sessionId':md5(_0x1cf8fd)})[_0x5829('0x29')](function(_0x37b31b){logger['info'](JSON['stringify'](_0x37b31b));return{'source':_0x37b31b[_0x5829('0x57')][_0x5829('0x58')],'resolvedQuery':_0x37b31b[_0x5829('0x57')]['resolvedQuery'],'action':_0x37b31b[_0x5829('0x57')][_0x5829('0x59')],'actionIncomplete':_0x37b31b[_0x5829('0x57')][_0x5829('0x5a')],'speech':_0x37b31b[_0x5829('0x57')][_0x5829('0x5b')][_0x5829('0x5c')],'score':_0x37b31b[_0x5829('0x57')][_0x5829('0x5d')],'statusCode':_0x37b31b[_0x5829('0x5e')][_0x5829('0x5f')],'endConversation':_0x37b31b['result'][_0x5829('0x60')]['endConversation']||![],'isFallbackIntent':_0x37b31b[_0x5829('0x57')]['metadata'][_0x5829('0x61')]};});};exports['googleDialogflowV2']=function(_0x1685f6,_0x2da0ae,_0x5a4e4d,_0x52f5c6,_0x37cec8,_0x16a5af){var _0x56b1c4=_0x52f5c6[_0x5829('0x62')](/\\n/g,'\x0a');var _0x357159={'credentials':{'private_key':_0x56b1c4,'client_email':_0x5a4e4d}};var _0x1967a2=new dialogflow[(_0x5829('0x63'))](_0x357159);var _0x3025b0=_0x1967a2[_0x5829('0x64')](_0x2da0ae,md5(_0x1685f6));var _0x4a97c3={'session':_0x3025b0,'queryInput':{'text':{'text':_0x37cec8,'languageCode':_0x16a5af}}};return _0x1967a2['detectIntent'](_0x4a97c3)[_0x5829('0x29')](function(_0x3cc7ef){if(_0x3cc7ef&&_0x3cc7ef['length']){logger['info'](_0x5829('0x65'),JSON[_0x5829('0x40')](_0x3cc7ef));var _0x31fb59=_0x3cc7ef[0x0];if(_0x31fb59){var _0x5b940d={'action':_0x31fb59[_0x5829('0x66')]['action'],'allRequiredParamsPresent':_0x31fb59['queryResult'][_0x5829('0x67')],'endConversation':_0x31fb59[_0x5829('0x66')]['diagnosticInfo']&&_0x31fb59[_0x5829('0x66')][_0x5829('0x68')]['fields']?_0x31fb59[_0x5829('0x66')][_0x5829('0x68')][_0x5829('0x69')][_0x5829('0x6a')][_0x5829('0x6b')]:![],'fulfillmentText':_0x31fb59['queryResult'][_0x5829('0x6c')],'intentName':_0x31fb59[_0x5829('0x66')][_0x5829('0x6d')][_0x5829('0x55')],'intentDisplayName':_0x31fb59[_0x5829('0x66')][_0x5829('0x6d')][_0x5829('0x6e')],'isFallbackIntent':_0x31fb59[_0x5829('0x66')]['intent']['isFallback'],'languageCode':_0x31fb59['queryResult'][_0x5829('0x6f')],'queryText':_0x31fb59[_0x5829('0x66')][_0x5829('0x70')],'responseId':_0x31fb59['responseId'],'score':_0x31fb59['queryResult']['intentDetectionConfidence'],'speech':_0x31fb59[_0x5829('0x66')][_0x5829('0x6c')],'providerResponse':JSON['stringify'](_0x3cc7ef)};return _0x5b940d;}}});};exports['tildeASR']=function(_0x5252af,_0x10c05d,_0x36b1cc,_0x2a6552){return tilde[_0x5829('0x4a')](_0x5252af,_0x10c05d,_0x36b1cc,_0x2a6552)[_0x5829('0x29')](function(_0x7ab8ab){try{fs[_0x5829('0x1c')](_0x5252af);}catch(_0x573864){logger['error'](_0x573864);}logger['info'](_0x5829('0x71'),_0x7ab8ab[_0x5829('0x4e')]);logger[_0x5829('0x1a')](_0x5829('0x72'),_0x7ab8ab[_0x5829('0x50')]);return _0x7ab8ab;});};exports[_0x5829('0x73')]=function(_0x33c51f,_0x34d4f7,_0x22012f,_0x5ba90b,_0x45730e,_0x5ea28b){var _0xf6c08e=path[_0x5829('0x26')](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+_0x5829('0x38'));var _0x26cb5f;return aws[_0x5829('0x74')](_0x33c51f,_0x34d4f7,_0x22012f,_0x5ba90b,_0x45730e,_0x5ea28b,_0xf6c08e)[_0x5829('0x29')](function(){_0x26cb5f=path['resolve'](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+_0x5829('0x3c'));return convertFile(_0xf6c08e,_0x26cb5f);})[_0x5829('0x29')](function(){try{fs[_0x5829('0x1c')](_0xf6c08e);fs[_0x5829('0x2a')](_0x26cb5f,'777');}catch(_0x373ec6){logger[_0x5829('0x14')](_0x373ec6);}return _0x26cb5f[_0x5829('0x2c')]('.')[0x0];});};exports['awsLex']=function(_0xb8be1b,_0x2a0ce3,_0x1ec739,_0x58df3c,_0x2da6e2,_0x1c3eb4){return aws[_0x5829('0x75')](_0xb8be1b,_0x2a0ce3,_0x1ec739,_0x58df3c,_0x2da6e2,_0x1c3eb4)[_0x5829('0x29')](function(_0x59efcb){logger[_0x5829('0x1a')](JSON[_0x5829('0x40')](_0x59efcb));return _0x59efcb;});};exports[_0x5829('0x76')]=function(_0x4f85f9,_0x41c66d,_0x58b51f,_0x105ef7){var _0x1c5dc8=util['format'](_0x5829('0x77'),ISPEECH_API,_0x4f85f9,encodeURIComponent(_0x41c66d),_0x58b51f,_0x105ef7);var _0x4e284b=path[_0x5829('0x26')](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+'.mp3');var _0x15af87;return downloadFile(_0x1c5dc8,_0x4e284b)[_0x5829('0x29')](function(){_0x15af87=path[_0x5829('0x26')](__dirname,_0x5829('0x37'),rs[_0x5829('0x27')](0x4)+'.wav');return convertFile(_0x4e284b,_0x15af87);})[_0x5829('0x29')](function(){try{fs[_0x5829('0x1c')](_0x4e284b);fs[_0x5829('0x2a')](_0x15af87,_0x5829('0x2b'));}catch(_0x1ac650){logger[_0x5829('0x14')](_0x1ac650);}return _0x15af87[_0x5829('0x2c')]('.')[0x0];});};exports[_0x5829('0x78')]=function(_0x68338f,_0x39fad0,_0x11c74f,_0x28cc5c){var _0x12c08c=util[_0x5829('0x79')](_0x5829('0x7a'),ISPEECH_API,_0x39fad0,_0x11c74f,base64Encode(_0x68338f),_0x28cc5c?util[_0x5829('0x79')](_0x5829('0x7b'),encodeURIComponent(_0x28cc5c)):_0x5829('0x7c'));return uploadFile(_0x12c08c)[_0x5829('0x29')](function(_0x5f31a9){return querystring[_0x5829('0x7d')](_0x5f31a9);});};exports['sestekNDA']=function(_0x440534,_0x35d57c){return sestek[_0x5829('0x7e')](_0x440534,_0x35d57c)[_0x5829('0x29')](function(_0x59f4d7){logger['info'](JSON[_0x5829('0x40')](_0x59f4d7));var _0x51495d={'speech':_0x59f4d7[_0x5829('0x7f')],'action':_0x59f4d7[_0x5829('0x80')]?_0x59f4d7[_0x5829('0x80')][_0x5829('0x81')]:undefined,'actiondata':_0x59f4d7[_0x5829('0x80')]?_0x59f4d7['channelData']['CustomActionData']:undefined};if(_0x59f4d7[_0x5829('0x80')]&&_0x59f4d7[_0x5829('0x80')][_0x5829('0x82')]){return base64Decode(_0x59f4d7['channelData'][_0x5829('0x82')][_0x5829('0x83')],path[_0x5829('0x26')](__dirname,_0x5829('0x37'),rs['generate'](0x4)+'.wav'))[_0x5829('0x29')](function(_0xbff310){_0x51495d[_0x5829('0x84')]=_0xbff310;return _0x51495d;});}return _0x51495d;});};exports[_0x5829('0x85')]=function(){return __dirname;};