Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / services / agi / scripts / index.js
index b499e67..bcc2cf8 100644 (file)
@@ -1 +1 @@
-const a1040_0x52fb=['statusCode','protocol','util','statusMessage','result','tmp','lex','ispeechASR','speech','toString','freeform=3','http','../../../config/logger','end','endConversation','pathname','./google','path','audioConfig','asr','catch','split','text','ssml','google-tts-api','Tilde\x20ASR\x20transcription','%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3','https://api.ispeech.org/api/rest','transcode','actionIncomplete','WHAT_EVER','join','parse','createWriteStream','apiai-promise','writeFileSync','stringify','metadata','get','nda','dirName','voice','fulfillment','request\x20to\x20','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','googleDialogflow','host','format','POST','confidence','googleASR','Data','md5','randomstring','text:synthesize','\x20failed,\x20status\x20code\x20=\x20','agi','input','querystring','readFileSync','results','error','chmodSync','?key=','info','alternatives','source','777','sestekNDA','writeFile','googleTTS','audiofile','error\x20convert','request-promise-native','googleASR\x20transcription','https','then','base64','pipe','close','transcript','message','polly','data','resolvedQuery','status','sox','map','goggleTTS\x20path','resolve','ispeechTTS','download\x20error','https://texttospeech.googleapis.com/v1/','unlink','url','.wav','name','finish\x20to\x20convert','model=%s','tildeASR','generate','./aws','Tilde\x20ASR\x20confidence','textRequest','channelData','.mp3','audioContent','wav','finish\x20download\x20file'];(function(_0x3e709c,_0x52fb0d){const _0x1a1af3=function(_0x58aabd){while(--_0x58aabd){_0x3e709c['push'](_0x3e709c['shift']());}};_0x1a1af3(++_0x52fb0d);}(a1040_0x52fb,0x1db));const a1040_0x1a1a=function(_0x3e709c,_0x52fb0d){_0x3e709c=_0x3e709c-0x0;let _0x1a1af3=a1040_0x52fb[_0x3e709c];return _0x1a1af3;};const _0xa89d81=a1040_0x1a1a;'use strict';const fs=require('fs'),path=require(_0xa89d81('0x57')),http=require(_0xa89d81('0x51')),https=require(_0xa89d81('0x24')),{URL}=require(_0xa89d81('0x37')),rs=require(_0xa89d81('0xe')),sox=require(_0xa89d81('0x2f')),rp=require(_0xa89d81('0x22')),util=require(_0xa89d81('0x48')),querystring=require(_0xa89d81('0x13')),tts=require(_0xa89d81('0x5e')),apiai=require(_0xa89d81('0x68')),md5=require(_0xa89d81('0xd')),google=require(_0xa89d81('0x56')),aws=require(_0xa89d81('0x3e')),tilde=require('./tilde'),sestek=require('./sestek'),logger=require(_0xa89d81('0x52'))(_0xa89d81('0x11')),ISPEECH_API=_0xa89d81('0x61');function downloadFile(_0x58aabd,_0x4493ad){return new Promise(function(_0x1c156b,_0x510ec2){const _0x2eeae2=a1040_0x1a1a,_0x66efc7=new URL(_0x58aabd),_0x1c5657=_0x66efc7[_0x2eeae2('0x47')]==='https:'?https:http,_0x29fa10={'host':_0x66efc7[_0x2eeae2('0x7')],'path':_0x66efc7[_0x2eeae2('0x55')],'headers':{'user-agent':_0x2eeae2('0x64')}};_0x1c5657[_0x2eeae2('0x6c')](_0x29fa10,function(_0x590fa0){const _0x4006d4=_0x2eeae2;if(_0x590fa0[_0x4006d4('0x46')]!==0xc8){logger[_0x4006d4('0x16')](_0x4006d4('0x4')+_0x58aabd+_0x4006d4('0x10')+_0x590fa0['statusCode']+'\x20('+_0x590fa0['statusMessage']+')'),_0x510ec2(new Error(_0x4006d4('0x4')+_0x58aabd+_0x4006d4('0x10')+_0x590fa0[_0x4006d4('0x46')]+'\x20('+_0x590fa0[_0x4006d4('0x49')]+')'));return;}const _0x75c7b=fs[_0x4006d4('0x67')](_0x4493ad);_0x75c7b['on']('finish',function(){const _0xedbac5=_0x4006d4;logger[_0xedbac5('0x19')](_0xedbac5('0x45')),_0x75c7b[_0xedbac5('0x28')](_0x1c156b);}),_0x75c7b['on'](_0x4006d4('0x16'),function(_0x3a3589){const _0x2eedc9=_0x4006d4;fs[_0x2eedc9('0x36')](_0x4493ad),logger[_0x2eedc9('0x16')](_0x2eedc9('0x34'),_0x3a3589),_0x510ec2(_0x3a3589);}),_0x590fa0[_0x4006d4('0x27')](_0x75c7b);})['on'](_0x2eeae2('0x16'),function(_0x51a74c){const _0x28dbbb=_0x2eeae2;logger[_0x28dbbb('0x16')](_0x51a74c),_0x510ec2(_0x51a74c);})[_0x2eeae2('0x53')]();});}function uploadFile(_0x20a099){return new Promise(function(_0x59ce11,_0x38ae0a){const _0x296256=a1040_0x1a1a,_0xb94689=new URL(_0x20a099),_0x592fd1=_0xb94689['protocol']==='https:'?https:http,_0x46ab1d={'host':_0xb94689[_0x296256('0x7')],'path':_0xb94689['pathname'],'headers':{'user-agent':_0x296256('0x64')}};_0x592fd1['get'](_0x46ab1d,function(_0x282839){const _0x295f98=_0x296256;if(_0x282839[_0x295f98('0x46')]!==0xc8){_0x38ae0a(new Error(_0x295f98('0x4')+_0x20a099+_0x295f98('0x10')+_0x282839[_0x295f98('0x46')]+'\x20('+_0x282839['statusMessage']+')'));return;}let _0xa792d5='';_0x282839['on'](_0x295f98('0x2c'),function(_0x35072d){_0xa792d5+=_0x35072d;}),_0x282839['on'](_0x295f98('0x53'),function(){_0x59ce11(_0xa792d5);});})['on'](_0x296256('0x16'),function(_0x19efdc){_0x38ae0a(_0x19efdc);})[_0x296256('0x53')]();});}function convertFile(_0x278cdd,_0xc5b62d){return new Promise(function(_0x593ab6,_0x5f0659){const _0x29166c=a1040_0x1a1a,_0xd250b2=sox[_0x29166c('0x62')](_0x278cdd,_0xc5b62d,{'sampleRate':0x1f40,'format':_0x29166c('0x44'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0xd250b2['on'](_0x29166c('0x16'),function(_0x53a2fe){const _0x82beec=_0x29166c;logger[_0x82beec('0x16')](_0x82beec('0x21'),_0x53a2fe),_0x5f0659(_0x53a2fe);}),_0xd250b2['on'](_0x29166c('0x53'),function(){const _0x24c341=_0x29166c;logger[_0x24c341('0x19')](_0x24c341('0x3a')),_0x593ab6();}),_0xd250b2['start']();});}function base64Decode(_0x591972,_0x20a2b5){const _0x2ce431=_0xa89d81,_0x3ebb9f=path[_0x2ce431('0x32')](__dirname,_0x2ce431('0x4b'),rs[_0x2ce431('0x3d')](0x4)+_0x2ce431('0x38'));return fs[_0x2ce431('0x69')](_0x3ebb9f,_0x591972,_0x2ce431('0x26')),convertFile(_0x3ebb9f,_0x20a2b5)[_0x2ce431('0x25')](function(){const _0x367bcd=_0x2ce431;try{fs[_0x367bcd('0x36')](_0x3ebb9f),fs['chmodSync'](_0x20a2b5,_0x367bcd('0x1c'));}catch(_0x496e83){logger['error'](_0x496e83);}return _0x20a2b5[_0x367bcd('0x5b')]('.')[0x0];});}function base64Encode(_0x51d68c){const _0x234ab7=_0xa89d81,_0x434857=fs[_0x234ab7('0x14')](_0x51d68c);return Buffer['from'](_0x434857)[_0x234ab7('0x4f')](_0x234ab7('0x26'));}exports['googleCloudTTS']=function(_0x2a76f1,_0x4bb6d3,_0x386732,_0x5764e6,_0x1080bd){const _0x31628a=_0xa89d81;let _0x2374f3,_0x596981;const _0x2149d5=_0x31628a('0x35'),_0x20443b=_0x31628a('0x18')+_0x2a76f1,_0x192b58={};_0x4bb6d3===_0x31628a('0x5d')?_0x192b58['input']={'ssml':_0x386732}:_0x192b58[_0x31628a('0x12')]={'text':_0x386732};_0x192b58[_0x31628a('0x2')]={'languageCode':_0x5764e6,'ssmlGender':_0x1080bd},_0x192b58[_0x31628a('0x58')]={'audioEncoding':'MP3','sampleRateHertz':0x1f40};const _0x226dac={'url':_0x2149d5+_0x31628a('0xf')+_0x20443b,'method':_0x31628a('0x9'),'json':!![],'body':_0x192b58};return rp(_0x226dac)[_0x31628a('0x25')](function(_0x34350b){return new Promise(function(_0x5eeaaa,_0x22ed99){const _0x3d42c6=a1040_0x1a1a;_0x2374f3=path[_0x3d42c6('0x32')](__dirname,_0x3d42c6('0x4b'),rs[_0x3d42c6('0x3d')](0x4)+'.mp3');const _0x21a287=Buffer['from'](_0x34350b[_0x3d42c6('0x43')],_0x3d42c6('0x26'));return fs[_0x3d42c6('0x1e')](_0x2374f3,_0x21a287,function(_0x850c13){_0x22ed99(_0x850c13);},function(_0x31ccf0){const _0x44e9aa=_0x3d42c6;fs[_0x44e9aa('0x17')](_0x2374f3,'777'),_0x5eeaaa(_0x31ccf0);});});})[_0x31628a('0x25')](function(){const _0x4e068f=_0x31628a;return _0x596981=path[_0x4e068f('0x32')](__dirname,_0x4e068f('0x4b'),rs[_0x4e068f('0x3d')](0x4)+_0x4e068f('0x38')),convertFile(_0x2374f3,_0x596981);})[_0x31628a('0x25')](function(){const _0x25d6db=_0x31628a;try{fs[_0x25d6db('0x36')](_0x2374f3),fs[_0x25d6db('0x17')](_0x596981,_0x25d6db('0x1c'));}catch(_0x5ddbd5){logger[_0x25d6db('0x16')](_0x5ddbd5);}return logger['info']('googleCloudTTS\x20path',_0x596981[_0x25d6db('0x5b')]('.')[0x0]),_0x596981[_0x25d6db('0x5b')]('.')[0x0];});},exports[_0xa89d81('0x1f')]=function(_0x51c9ed,_0x343345){const _0x116176=_0xa89d81;let _0x2daa4b,_0xe6e80e;return tts(_0x51c9ed,_0x343345||'en',0x1)[_0x116176('0x25')](function(_0x40dfa6){const _0x5af279=_0x116176;return logger[_0x5af279('0x19')](_0x40dfa6),_0x2daa4b=path[_0x5af279('0x32')](__dirname,_0x5af279('0x4b'),rs[_0x5af279('0x3d')](0x4)+_0x5af279('0x42')),downloadFile(_0x40dfa6,_0x2daa4b);})[_0x116176('0x25')](function(){const _0x101cac=_0x116176;return _0xe6e80e=path['resolve'](__dirname,_0x101cac('0x4b'),rs[_0x101cac('0x3d')](0x4)+_0x101cac('0x38')),convertFile(_0x2daa4b,_0xe6e80e);})[_0x116176('0x25')](function(){const _0x528e2f=_0x116176;try{fs['unlink'](_0x2daa4b),fs[_0x528e2f('0x17')](_0xe6e80e,'777');}catch(_0x56df25){logger[_0x528e2f('0x16')](_0x56df25);}return logger[_0x528e2f('0x19')](_0x528e2f('0x31'),_0xe6e80e[_0x528e2f('0x5b')]('.')[0x0]),_0xe6e80e[_0x528e2f('0x5b')]('.')[0x0];});},exports[_0xa89d81('0xb')]=function(_0xa68cc,_0x42ba8c,_0x497daa){const _0x5a852f=_0xa89d81;return google[_0x5a852f('0x59')](_0xa68cc,_0x42ba8c,_0x497daa)[_0x5a852f('0x25')](function(_0x4bad90){const _0x30c194=_0x5a852f;return logger[_0x30c194('0x19')](_0x4bad90['uri']),rp(_0x4bad90);})['then'](function(_0x4f9abf){const _0x3d7657=_0x5a852f;let _0x5809e7='',_0x16c868=0x0;try{fs[_0x3d7657('0x36')](_0xa68cc);}catch(_0xb5698){logger[_0x3d7657('0x16')](_0xb5698);}return _0x4f9abf&&_0x4f9abf[_0x3d7657('0x15')]&&(_0x5809e7=_0x4f9abf[_0x3d7657('0x15')][_0x3d7657('0x30')](function(_0x4fdec5){const _0x1c8221=_0x3d7657;return _0x4fdec5&&_0x4fdec5['alternatives'][0x0]&&_0x4fdec5[_0x1c8221('0x1a')][0x0][_0x1c8221('0x29')]?_0x4fdec5['alternatives'][0x0]['transcript']:'';})['join']('\x0a'),_0x16c868=_0x4f9abf[_0x3d7657('0x15')][_0x3d7657('0x30')](function(_0x47b105){const _0x27878d=_0x3d7657;return _0x47b105&&_0x47b105[_0x27878d('0x1a')][0x0]&&_0x47b105['alternatives'][0x0][_0x27878d('0xa')]?_0x47b105[_0x27878d('0x1a')][0x0]['confidence']:0x0;})[_0x3d7657('0x65')]('\x0a')),logger[_0x3d7657('0x19')](_0x3d7657('0x23'),_0x5809e7),logger[_0x3d7657('0x19')]('googleASR\x20confidence',_0x16c868),{'transcript':_0x5809e7,'confidence':_0x16c868};})[_0x5a852f('0x5a')](function(_0x4ad1dd){const _0x1080f3=_0x5a852f;logger['error']('[%s]\x20%s:%s',_0x4ad1dd['statusCode'],_0x4ad1dd[_0x1080f3('0x39')],_0x4ad1dd[_0x1080f3('0x2a')]);});},exports[_0xa89d81('0x6')]=function(_0x389a27,_0x18611b,_0x1e73b6,_0xe69734){const _0x17dcee=_0xa89d81,_0xee1eb4=apiai(_0x18611b,{'language':_0xe69734||'en'});return _0xee1eb4[_0x17dcee('0x40')](_0x1e73b6,{'sessionId':md5(_0x389a27)})[_0x17dcee('0x25')](function(_0x168890){const _0x48757c=_0x17dcee;return logger['info'](JSON['stringify'](_0x168890)),{'source':_0x168890[_0x48757c('0x4a')][_0x48757c('0x1b')],'resolvedQuery':_0x168890[_0x48757c('0x4a')][_0x48757c('0x2d')],'action':_0x168890[_0x48757c('0x4a')]['action'],'actionIncomplete':_0x168890[_0x48757c('0x4a')][_0x48757c('0x63')],'speech':_0x168890['result'][_0x48757c('0x3')][_0x48757c('0x4e')],'score':_0x168890[_0x48757c('0x4a')]['score'],'statusCode':_0x168890[_0x48757c('0x2e')]['code'],'endConversation':_0x168890[_0x48757c('0x4a')][_0x48757c('0x6b')][_0x48757c('0x54')]||![],'isFallbackIntent':_0x168890[_0x48757c('0x4a')]['metadata']['isFallbackIntent']};});},exports[_0xa89d81('0x3c')]=function(_0x49a821,_0x16b255,_0x3b69c2,_0x4f51ac){return tilde['asr'](_0x49a821,_0x16b255,_0x3b69c2,_0x4f51ac)['then'](function(_0x40a105){const _0x40c0de=a1040_0x1a1a;try{fs[_0x40c0de('0x36')](_0x49a821);}catch(_0x40280c){logger['error'](_0x40280c);}return logger[_0x40c0de('0x19')](_0x40c0de('0x5f'),_0x40a105[_0x40c0de('0x29')]),logger[_0x40c0de('0x19')](_0x40c0de('0x3f'),_0x40a105[_0x40c0de('0xa')]),_0x40a105;});},exports['awsPolly']=function(_0x12f6d3,_0x42c38c,_0x505243,_0x1aaf8e,_0x1be3c2,_0x275c32){const _0x3f582d=_0xa89d81,_0x562223=path['resolve'](__dirname,_0x3f582d('0x4b'),rs[_0x3f582d('0x3d')](0x4)+_0x3f582d('0x42'));let _0x149cd8;return aws[_0x3f582d('0x2b')](_0x12f6d3,_0x42c38c,_0x505243,_0x1aaf8e,_0x1be3c2,_0x275c32,_0x562223)[_0x3f582d('0x25')](function(){const _0x219dcf=_0x3f582d;return _0x149cd8=path[_0x219dcf('0x32')](__dirname,_0x219dcf('0x4b'),rs['generate'](0x4)+'.wav'),convertFile(_0x562223,_0x149cd8);})['then'](function(){const _0x4d1c45=_0x3f582d;try{fs[_0x4d1c45('0x36')](_0x562223),fs[_0x4d1c45('0x17')](_0x149cd8,_0x4d1c45('0x1c'));}catch(_0x3030a7){logger[_0x4d1c45('0x16')](_0x3030a7);}return _0x149cd8[_0x4d1c45('0x5b')]('.')[0x0];});},exports['awsLex']=function(_0x2060a4,_0x12676e,_0x269f17,_0x25dd79,_0x10fefa,_0x523a02){const _0x4d718f=_0xa89d81;return aws[_0x4d718f('0x4c')](_0x2060a4,_0x12676e,_0x269f17,_0x25dd79,_0x10fefa,_0x523a02)[_0x4d718f('0x25')](function(_0x3fb28c){const _0xd3ab80=_0x4d718f;return logger[_0xd3ab80('0x19')](JSON['stringify'](_0x3fb28c)),_0x3fb28c;});},exports[_0xa89d81('0x33')]=function(_0x38987d,_0x21183c,_0x3c9373,_0x3d4acf){const _0xd5a6c3=_0xa89d81,_0x18a133=util[_0xd5a6c3('0x8')](_0xd5a6c3('0x60'),ISPEECH_API,_0x38987d,encodeURIComponent(_0x21183c),_0x3c9373,_0x3d4acf),_0x2783af=path[_0xd5a6c3('0x32')](__dirname,_0xd5a6c3('0x4b'),rs[_0xd5a6c3('0x3d')](0x4)+_0xd5a6c3('0x42'));let _0x153490;return downloadFile(_0x18a133,_0x2783af)[_0xd5a6c3('0x25')](function(){const _0x34a4d9=_0xd5a6c3;return _0x153490=path[_0x34a4d9('0x32')](__dirname,_0x34a4d9('0x4b'),rs[_0x34a4d9('0x3d')](0x4)+'.wav'),convertFile(_0x2783af,_0x153490);})['then'](function(){const _0x3d9f2f=_0xd5a6c3;try{fs[_0x3d9f2f('0x36')](_0x2783af),fs[_0x3d9f2f('0x17')](_0x153490,_0x3d9f2f('0x1c'));}catch(_0x2bd660){logger[_0x3d9f2f('0x16')](_0x2bd660);}return _0x153490[_0x3d9f2f('0x5b')]('.')[0x0];});},exports[_0xa89d81('0x4d')]=function(_0x300da7,_0x36bbca,_0x3d4652,_0x4e850b){const _0x1faf6e=_0xa89d81,_0x477c96=util[_0x1faf6e('0x8')](_0x1faf6e('0x5'),ISPEECH_API,_0x36bbca,_0x3d4652,base64Encode(_0x300da7),_0x4e850b?util[_0x1faf6e('0x8')](_0x1faf6e('0x3b'),encodeURIComponent(_0x4e850b)):_0x1faf6e('0x50'));return uploadFile(_0x477c96)[_0x1faf6e('0x25')](function(_0x4efea4){const _0x5464f1=_0x1faf6e;return querystring[_0x5464f1('0x66')](_0x4efea4);});},exports[_0xa89d81('0x1d')]=function(_0xfdbd3f,_0xc2d91a){const _0x5eb891=_0xa89d81;return sestek[_0x5eb891('0x0')](_0xfdbd3f,_0xc2d91a)[_0x5eb891('0x25')](function(_0x5d2cdf){const _0x2594ce=_0x5eb891;logger[_0x2594ce('0x19')](JSON[_0x2594ce('0x6a')](_0x5d2cdf));const _0x591b0e={'speech':_0x5d2cdf[_0x2594ce('0x5c')],'action':_0x5d2cdf[_0x2594ce('0x41')]?_0x5d2cdf[_0x2594ce('0x41')]['CustomAction']:undefined,'actiondata':_0x5d2cdf['channelData']?_0x5d2cdf[_0x2594ce('0x41')]['CustomActionData']:undefined};if(_0x5d2cdf[_0x2594ce('0x41')]&&_0x5d2cdf[_0x2594ce('0x41')]['AudioFromTts'])return base64Decode(_0x5d2cdf[_0x2594ce('0x41')]['AudioFromTts'][_0x2594ce('0xc')],path[_0x2594ce('0x32')](__dirname,_0x2594ce('0x4b'),rs[_0x2594ce('0x3d')](0x4)+_0x2594ce('0x38')))[_0x2594ce('0x25')](function(_0x4795d4){const _0x3a8c4d=_0x2594ce;return _0x591b0e[_0x3a8c4d('0x20')]=_0x4795d4,_0x591b0e;});return _0x591b0e;});},exports[_0xa89d81('0x1')]=function(){return __dirname;};
\ No newline at end of file
+const a1040_0x564b=['WHAT_EVER','map','googleTTS','agi','\x20failed,\x20status\x20code\x20=\x20','.mp3','createWriteStream','tmp','base64','result','ispeechASR','googleDialogflow','freeform=3','writeFileSync','confidence','googleASR','google-tts-api','pathname','googleASR\x20confidence','request\x20to\x20','https://api.ispeech.org/api/rest','?key=','fulfillment','uri','ispeechTTS','statusCode','format','catch','ssml','error\x20convert','dirName','chmodSync','statusMessage','get','text:synthesize','textRequest','url','util','error','toString','info','md5','.wav','CustomActionData','data','./aws','protocol','message','host','http','https://texttospeech.googleapis.com/v1/','transcript','asr','generate','voice','googleASR\x20transcription','randomstring','text','%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3','goggleTTS\x20path','resolvedQuery','stringify','unlink','transcode','path','Tilde\x20ASR\x20confidence','finish','awsLex','sestekNDA','end','wav','writeFile','split','apiai-promise','resolve','querystring','sox','AudioFromTts','lex','score','from','speech','close','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','./tilde','name','start','join','./sestek','POST','then','googleCloudTTS\x20path','action','MP3','results','polly','./google','readFileSync','finish\x20download\x20file','channelData','endConversation','tildeASR','metadata','request-promise-native','googleCloudTTS','audioConfig','Data','alternatives','777','https:','CustomAction','audiofile','nda','model=%s','actionIncomplete','parse'];(function(_0x2ab061,_0x564b58){const _0x1c3978=function(_0x10b87f){while(--_0x10b87f){_0x2ab061['push'](_0x2ab061['shift']());}};_0x1c3978(++_0x564b58);}(a1040_0x564b,0x14b));const a1040_0x1c39=function(_0x2ab061,_0x564b58){_0x2ab061=_0x2ab061-0x0;let _0x1c3978=a1040_0x564b[_0x2ab061];return _0x1c3978;};const _0x45b14a=a1040_0x1c39;'use strict';const fs=require('fs'),path=require(_0x45b14a('0x51')),http=require(_0x45b14a('0x42')),https=require('https'),{URL}=require(_0x45b14a('0x35')),rs=require(_0x45b14a('0x49')),sox=require(_0x45b14a('0x5d')),rp=require(_0x45b14a('0x4')),util=require(_0x45b14a('0x36')),querystring=require(_0x45b14a('0x5c')),tts=require(_0x45b14a('0x21')),apiai=require(_0x45b14a('0x5a')),md5=require(_0x45b14a('0x3a')),google=require(_0x45b14a('0x71')),aws=require(_0x45b14a('0x3e')),tilde=require(_0x45b14a('0x65')),sestek=require(_0x45b14a('0x69')),logger=require('../../../config/logger')(_0x45b14a('0x14')),ISPEECH_API=_0x45b14a('0x25');function downloadFile(_0x10b87f,_0x52f7a1){return new Promise(function(_0x224a5c,_0x2ab6b3){const _0x2cd901=a1040_0x1c39,_0x4f368d=new URL(_0x10b87f),_0x4c5e7a=_0x4f368d[_0x2cd901('0x3f')]===_0x2cd901('0xa')?https:http,_0x5d8c91={'host':_0x4f368d[_0x2cd901('0x41')],'path':_0x4f368d[_0x2cd901('0x22')],'headers':{'user-agent':_0x2cd901('0x11')}};_0x4c5e7a[_0x2cd901('0x32')](_0x5d8c91,function(_0x112f9a){const _0xba8ed2=_0x2cd901;if(_0x112f9a[_0xba8ed2('0x2a')]!==0xc8){logger['error']('request\x20to\x20'+_0x10b87f+_0xba8ed2('0x15')+_0x112f9a['statusCode']+'\x20('+_0x112f9a[_0xba8ed2('0x31')]+')'),_0x2ab6b3(new Error(_0xba8ed2('0x24')+_0x10b87f+'\x20failed,\x20status\x20code\x20=\x20'+_0x112f9a[_0xba8ed2('0x2a')]+'\x20('+_0x112f9a[_0xba8ed2('0x31')]+')'));return;}const _0x4ac6b6=fs[_0xba8ed2('0x17')](_0x52f7a1);_0x4ac6b6['on'](_0xba8ed2('0x53'),function(){const _0x57abc6=_0xba8ed2;logger[_0x57abc6('0x39')](_0x57abc6('0x73')),_0x4ac6b6[_0x57abc6('0x63')](_0x224a5c);}),_0x4ac6b6['on'](_0xba8ed2('0x37'),function(_0x1bd9cd){const _0x503cea=_0xba8ed2;fs[_0x503cea('0x4f')](_0x52f7a1),logger[_0x503cea('0x37')]('download\x20error',_0x1bd9cd),_0x2ab6b3(_0x1bd9cd);}),_0x112f9a['pipe'](_0x4ac6b6);})['on'](_0x2cd901('0x37'),function(_0x222f4c){logger['error'](_0x222f4c),_0x2ab6b3(_0x222f4c);})[_0x2cd901('0x56')]();});}function uploadFile(_0x1365fd){return new Promise(function(_0x272dd9,_0x5247a6){const _0x4f9140=a1040_0x1c39,_0x2507a6=new URL(_0x1365fd),_0x45dfb0=_0x2507a6[_0x4f9140('0x3f')]===_0x4f9140('0xa')?https:http,_0x57cc38={'host':_0x2507a6[_0x4f9140('0x41')],'path':_0x2507a6[_0x4f9140('0x22')],'headers':{'user-agent':_0x4f9140('0x11')}};_0x45dfb0[_0x4f9140('0x32')](_0x57cc38,function(_0x3d2cf7){const _0x4defcc=_0x4f9140;if(_0x3d2cf7[_0x4defcc('0x2a')]!==0xc8){_0x5247a6(new Error(_0x4defcc('0x24')+_0x1365fd+_0x4defcc('0x15')+_0x3d2cf7[_0x4defcc('0x2a')]+'\x20('+_0x3d2cf7[_0x4defcc('0x31')]+')'));return;}let _0x5dfc20='';_0x3d2cf7['on'](_0x4defcc('0x3d'),function(_0x3e8c5e){_0x5dfc20+=_0x3e8c5e;}),_0x3d2cf7['on'](_0x4defcc('0x56'),function(){_0x272dd9(_0x5dfc20);});})['on'](_0x4f9140('0x37'),function(_0x4a0c78){_0x5247a6(_0x4a0c78);})[_0x4f9140('0x56')]();});}function convertFile(_0x13fea7,_0x156a4d){return new Promise(function(_0x3f93e5,_0x4de7fa){const _0x577040=a1040_0x1c39,_0x1f1828=sox[_0x577040('0x50')](_0x13fea7,_0x156a4d,{'sampleRate':0x1f40,'format':_0x577040('0x57'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x1f1828['on'](_0x577040('0x37'),function(_0x4532bb){const _0x4f6182=_0x577040;logger[_0x4f6182('0x37')](_0x4f6182('0x2e'),_0x4532bb),_0x4de7fa(_0x4532bb);}),_0x1f1828['on'](_0x577040('0x56'),function(){const _0xba2fbf=_0x577040;logger[_0xba2fbf('0x39')]('finish\x20to\x20convert'),_0x3f93e5();}),_0x1f1828[_0x577040('0x67')]();});}function base64Decode(_0x4a13af,_0x3ccb53){const _0x568a6e=_0x45b14a,_0x5ae6ae=path[_0x568a6e('0x5b')](__dirname,_0x568a6e('0x18'),rs[_0x568a6e('0x46')](0x4)+'.wav');return fs[_0x568a6e('0x1e')](_0x5ae6ae,_0x4a13af,_0x568a6e('0x19')),convertFile(_0x5ae6ae,_0x3ccb53)[_0x568a6e('0x6b')](function(){const _0x163192=_0x568a6e;try{fs[_0x163192('0x4f')](_0x5ae6ae),fs[_0x163192('0x30')](_0x3ccb53,_0x163192('0x9'));}catch(_0x114507){logger[_0x163192('0x37')](_0x114507);}return _0x3ccb53[_0x163192('0x59')]('.')[0x0];});}function base64Encode(_0x34a725){const _0x4f2d38=_0x45b14a,_0x4846b3=fs[_0x4f2d38('0x72')](_0x34a725);return Buffer['from'](_0x4846b3)[_0x4f2d38('0x38')]('base64');}exports[_0x45b14a('0x5')]=function(_0x15743a,_0x27fb3d,_0x22aa8e,_0x34bf57,_0x190a0e){const _0x1966c1=_0x45b14a;let _0x49e89d,_0x25431e;const _0x294bf3=_0x1966c1('0x43'),_0x24077d=_0x1966c1('0x26')+_0x15743a,_0x5627ef={};_0x27fb3d===_0x1966c1('0x2d')?_0x5627ef['input']={'ssml':_0x22aa8e}:_0x5627ef['input']={'text':_0x22aa8e};_0x5627ef[_0x1966c1('0x47')]={'languageCode':_0x34bf57,'ssmlGender':_0x190a0e},_0x5627ef[_0x1966c1('0x6')]={'audioEncoding':_0x1966c1('0x6e'),'sampleRateHertz':0x1f40};const _0x1116aa={'url':_0x294bf3+_0x1966c1('0x33')+_0x24077d,'method':_0x1966c1('0x6a'),'json':!![],'body':_0x5627ef};return rp(_0x1116aa)[_0x1966c1('0x6b')](function(_0x4ea0fe){return new Promise(function(_0x1beabd,_0xba001b){const _0x110862=a1040_0x1c39;_0x49e89d=path[_0x110862('0x5b')](__dirname,_0x110862('0x18'),rs[_0x110862('0x46')](0x4)+'.mp3');const _0x314c94=Buffer[_0x110862('0x61')](_0x4ea0fe['audioContent'],'base64');return fs[_0x110862('0x58')](_0x49e89d,_0x314c94,function(_0x3f2daf){_0xba001b(_0x3f2daf);},function(_0x2da653){const _0xc2b824=_0x110862;fs[_0xc2b824('0x30')](_0x49e89d,_0xc2b824('0x9')),_0x1beabd(_0x2da653);});});})[_0x1966c1('0x6b')](function(){const _0x132ea9=_0x1966c1;return _0x25431e=path['resolve'](__dirname,_0x132ea9('0x18'),rs[_0x132ea9('0x46')](0x4)+_0x132ea9('0x3b')),convertFile(_0x49e89d,_0x25431e);})[_0x1966c1('0x6b')](function(){const _0xdfbd38=_0x1966c1;try{fs[_0xdfbd38('0x4f')](_0x49e89d),fs[_0xdfbd38('0x30')](_0x25431e,_0xdfbd38('0x9'));}catch(_0x242c4a){logger['error'](_0x242c4a);}return logger[_0xdfbd38('0x39')](_0xdfbd38('0x6c'),_0x25431e[_0xdfbd38('0x59')]('.')[0x0]),_0x25431e[_0xdfbd38('0x59')]('.')[0x0];});},exports[_0x45b14a('0x13')]=function(_0x348827,_0x4add53){const _0x3e2058=_0x45b14a;let _0x63d86,_0x41b658;return tts(_0x348827,_0x4add53||'en',0x1)[_0x3e2058('0x6b')](function(_0x132fb9){const _0x4757e0=_0x3e2058;return logger['info'](_0x132fb9),_0x63d86=path[_0x4757e0('0x5b')](__dirname,_0x4757e0('0x18'),rs['generate'](0x4)+_0x4757e0('0x16')),downloadFile(_0x132fb9,_0x63d86);})['then'](function(){const _0x1a7df3=_0x3e2058;return _0x41b658=path[_0x1a7df3('0x5b')](__dirname,'tmp',rs[_0x1a7df3('0x46')](0x4)+_0x1a7df3('0x3b')),convertFile(_0x63d86,_0x41b658);})['then'](function(){const _0x34c7f9=_0x3e2058;try{fs[_0x34c7f9('0x4f')](_0x63d86),fs[_0x34c7f9('0x30')](_0x41b658,_0x34c7f9('0x9'));}catch(_0x61b799){logger[_0x34c7f9('0x37')](_0x61b799);}return logger[_0x34c7f9('0x39')](_0x34c7f9('0x4c'),_0x41b658[_0x34c7f9('0x59')]('.')[0x0]),_0x41b658[_0x34c7f9('0x59')]('.')[0x0];});},exports[_0x45b14a('0x20')]=function(_0x399ae8,_0xc3c8de,_0x4255ca){const _0x4cd37f=_0x45b14a;return google[_0x4cd37f('0x45')](_0x399ae8,_0xc3c8de,_0x4255ca)['then'](function(_0x31960c){const _0x555dee=_0x4cd37f;return logger[_0x555dee('0x39')](_0x31960c[_0x555dee('0x28')]),rp(_0x31960c);})[_0x4cd37f('0x6b')](function(_0x580401){const _0x3179aa=_0x4cd37f;let _0x4e57cd='',_0x4c635a=0x0;try{fs[_0x3179aa('0x4f')](_0x399ae8);}catch(_0x14e00f){logger[_0x3179aa('0x37')](_0x14e00f);}return _0x580401&&_0x580401[_0x3179aa('0x6f')]&&(_0x4e57cd=_0x580401[_0x3179aa('0x6f')]['map'](function(_0x5e6a91){const _0x2c46c9=_0x3179aa;return _0x5e6a91&&_0x5e6a91[_0x2c46c9('0x8')][0x0]&&_0x5e6a91[_0x2c46c9('0x8')][0x0]['transcript']?_0x5e6a91[_0x2c46c9('0x8')][0x0][_0x2c46c9('0x44')]:'';})[_0x3179aa('0x68')]('\x0a'),_0x4c635a=_0x580401['results'][_0x3179aa('0x12')](function(_0x1d484e){const _0x730933=_0x3179aa;return _0x1d484e&&_0x1d484e[_0x730933('0x8')][0x0]&&_0x1d484e['alternatives'][0x0]['confidence']?_0x1d484e[_0x730933('0x8')][0x0][_0x730933('0x1f')]:0x0;})[_0x3179aa('0x68')]('\x0a')),logger[_0x3179aa('0x39')](_0x3179aa('0x48'),_0x4e57cd),logger[_0x3179aa('0x39')](_0x3179aa('0x23'),_0x4c635a),{'transcript':_0x4e57cd,'confidence':_0x4c635a};})[_0x4cd37f('0x2c')](function(_0x238136){const _0x17eda9=_0x4cd37f;logger[_0x17eda9('0x37')]('[%s]\x20%s:%s',_0x238136['statusCode'],_0x238136[_0x17eda9('0x66')],_0x238136[_0x17eda9('0x40')]);});},exports[_0x45b14a('0x1c')]=function(_0xf2aa0d,_0x2fb386,_0x2bcc6f,_0x48d2da){const _0x553f2e=_0x45b14a,_0x45c963=apiai(_0x2fb386,{'language':_0x48d2da||'en'});return _0x45c963[_0x553f2e('0x34')](_0x2bcc6f,{'sessionId':md5(_0xf2aa0d)})[_0x553f2e('0x6b')](function(_0x47569f){const _0x3b5e14=_0x553f2e;return logger[_0x3b5e14('0x39')](JSON['stringify'](_0x47569f)),{'source':_0x47569f['result']['source'],'resolvedQuery':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0x4d')],'action':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0x6d')],'actionIncomplete':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0xf')],'speech':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0x27')][_0x3b5e14('0x62')],'score':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0x60')],'statusCode':_0x47569f['status']['code'],'endConversation':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0x3')][_0x3b5e14('0x1')]||![],'isFallbackIntent':_0x47569f[_0x3b5e14('0x1a')][_0x3b5e14('0x3')]['isFallbackIntent']};});},exports[_0x45b14a('0x2')]=function(_0x8e361c,_0x34362c,_0x3da088,_0x579331){const _0x2e9204=_0x45b14a;return tilde['asr'](_0x8e361c,_0x34362c,_0x3da088,_0x579331)[_0x2e9204('0x6b')](function(_0x7f7508){const _0x10b768=_0x2e9204;try{fs[_0x10b768('0x4f')](_0x8e361c);}catch(_0x675e00){logger['error'](_0x675e00);}return logger[_0x10b768('0x39')]('Tilde\x20ASR\x20transcription',_0x7f7508[_0x10b768('0x44')]),logger[_0x10b768('0x39')](_0x10b768('0x52'),_0x7f7508[_0x10b768('0x1f')]),_0x7f7508;});},exports['awsPolly']=function(_0x4f4922,_0x5ace46,_0x10fb09,_0x2b7dd9,_0x524671,_0x1d88a7){const _0x41d4a9=_0x45b14a,_0xa2722=path[_0x41d4a9('0x5b')](__dirname,_0x41d4a9('0x18'),rs[_0x41d4a9('0x46')](0x4)+_0x41d4a9('0x16'));let _0x44b0cc;return aws[_0x41d4a9('0x70')](_0x4f4922,_0x5ace46,_0x10fb09,_0x2b7dd9,_0x524671,_0x1d88a7,_0xa2722)['then'](function(){const _0x1cc6df=_0x41d4a9;return _0x44b0cc=path['resolve'](__dirname,_0x1cc6df('0x18'),rs['generate'](0x4)+'.wav'),convertFile(_0xa2722,_0x44b0cc);})[_0x41d4a9('0x6b')](function(){const _0x52e9c3=_0x41d4a9;try{fs[_0x52e9c3('0x4f')](_0xa2722),fs[_0x52e9c3('0x30')](_0x44b0cc,'777');}catch(_0x24a364){logger[_0x52e9c3('0x37')](_0x24a364);}return _0x44b0cc[_0x52e9c3('0x59')]('.')[0x0];});},exports[_0x45b14a('0x54')]=function(_0x1277e3,_0x536bfd,_0x5286c2,_0x17a836,_0xc5f67f,_0x5c5ed4){const _0x2c8a01=_0x45b14a;return aws[_0x2c8a01('0x5f')](_0x1277e3,_0x536bfd,_0x5286c2,_0x17a836,_0xc5f67f,_0x5c5ed4)[_0x2c8a01('0x6b')](function(_0x395173){const _0x9dbcce=_0x2c8a01;return logger['info'](JSON[_0x9dbcce('0x4e')](_0x395173)),_0x395173;});},exports[_0x45b14a('0x29')]=function(_0x581ffd,_0x460aa8,_0x8f1796,_0x55fb15){const _0x3396fc=_0x45b14a,_0x16abcc=util[_0x3396fc('0x2b')](_0x3396fc('0x4b'),ISPEECH_API,_0x581ffd,encodeURIComponent(_0x460aa8),_0x8f1796,_0x55fb15),_0x331c5a=path[_0x3396fc('0x5b')](__dirname,_0x3396fc('0x18'),rs[_0x3396fc('0x46')](0x4)+_0x3396fc('0x16'));let _0x34e26c;return downloadFile(_0x16abcc,_0x331c5a)[_0x3396fc('0x6b')](function(){const _0x53018a=_0x3396fc;return _0x34e26c=path[_0x53018a('0x5b')](__dirname,_0x53018a('0x18'),rs[_0x53018a('0x46')](0x4)+_0x53018a('0x3b')),convertFile(_0x331c5a,_0x34e26c);})[_0x3396fc('0x6b')](function(){const _0x4d124f=_0x3396fc;try{fs[_0x4d124f('0x4f')](_0x331c5a),fs['chmodSync'](_0x34e26c,_0x4d124f('0x9'));}catch(_0x383baa){logger[_0x4d124f('0x37')](_0x383baa);}return _0x34e26c['split']('.')[0x0];});},exports[_0x45b14a('0x1b')]=function(_0x10dc6a,_0x398e1a,_0x34efbb,_0x4e7d87){const _0x590f34=_0x45b14a,_0x25f1ab=util['format'](_0x590f34('0x64'),ISPEECH_API,_0x398e1a,_0x34efbb,base64Encode(_0x10dc6a),_0x4e7d87?util[_0x590f34('0x2b')](_0x590f34('0xe'),encodeURIComponent(_0x4e7d87)):_0x590f34('0x1d'));return uploadFile(_0x25f1ab)[_0x590f34('0x6b')](function(_0x42395c){const _0x2c50a6=_0x590f34;return querystring[_0x2c50a6('0x10')](_0x42395c);});},exports[_0x45b14a('0x55')]=function(_0x1868f0,_0x10f128){const _0x49c09f=_0x45b14a;return sestek[_0x49c09f('0xd')](_0x1868f0,_0x10f128)[_0x49c09f('0x6b')](function(_0x5edd71){const _0x2daaad=_0x49c09f;logger[_0x2daaad('0x39')](JSON[_0x2daaad('0x4e')](_0x5edd71));const _0x33518b={'speech':_0x5edd71[_0x2daaad('0x4a')],'action':_0x5edd71[_0x2daaad('0x0')]?_0x5edd71['channelData'][_0x2daaad('0xb')]:undefined,'actiondata':_0x5edd71[_0x2daaad('0x0')]?_0x5edd71['channelData'][_0x2daaad('0x3c')]:undefined};if(_0x5edd71[_0x2daaad('0x0')]&&_0x5edd71['channelData']['AudioFromTts'])return base64Decode(_0x5edd71['channelData'][_0x2daaad('0x5e')][_0x2daaad('0x7')],path[_0x2daaad('0x5b')](__dirname,'tmp',rs[_0x2daaad('0x46')](0x4)+_0x2daaad('0x3b')))[_0x2daaad('0x6b')](function(_0x428904){const _0x1730e2=_0x2daaad;return _0x33518b[_0x1730e2('0xc')]=_0x428904,_0x33518b;});return _0x33518b;});},exports[_0x45b14a('0x2f')]=function(){return __dirname;};
\ No newline at end of file