Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / services / agi / scripts / index.js
index 842e8c6..eae6a84 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd263=['readFileSync','toString','base64','googleCloudTTS','?key=','ssml','input','voice','audioConfig','MP3','text:synthesize','POST','then','.mp3','from','audioContent','writeFile','777','googleCloudTTS\x20path','split','goggleTTS\x20path','googleASR','asr','uri','results','map','alternatives','transcript','join','confidence','googleASR\x20transcription','googleASR\x20confidence','catch','[%s]\x20%s:%s','message','googleDialogflow','textRequest','result','resolvedQuery','action','actionIncomplete','fulfillment','speech','score','code','metadata','endConversation','tildeASR','Tilde\x20ASR\x20transcription','Tilde\x20ASR\x20confidence','awsPolly','polly','awsLex','lex','stringify','ispeechTTS','format','ispeechASR','%s?apikey=%s&action=recognize&locale=%s&content-type=audio/x-wav&audio=%s&%s','model=%s','sestekNDA','text','channelData','CustomActionData','AudioFromTts','Data','audiofile','dirName','path','http','https','url','parse','randomstring','sox','request-promise','util','querystring','google-tts-api','./aws','./tilde','../../../config/logger','agi','https://api.ispeech.org/api/rest','protocol','https:','host','WHAT_EVER','get','error','request\x20to\x20','\x20failed,\x20status\x20code\x20=\x20','statusCode','statusMessage','createWriteStream','finish','info','unlink','pipe','end','transcode','wav','error\x20convert','finish\x20to\x20convert','start','resolve','tmp','generate','.wav','writeFileSync','chmodSync'];(function(_0x67754c,_0x4ee2c1){var _0x1f09ec=function(_0x255080){while(--_0x255080){_0x67754c['push'](_0x67754c['shift']());}};_0x1f09ec(++_0x4ee2c1);}(_0xd263,0xb3));var _0x3d26=function(_0x9abf28,_0x10566d){_0x9abf28=_0x9abf28-0x0;var _0x20b418=_0xd263[_0x9abf28];return _0x20b418;};'use strict';var fs=require('fs');var path=require(_0x3d26('0x0'));var http=require(_0x3d26('0x1'));var https=require(_0x3d26('0x2'));var urlParse=require(_0x3d26('0x3'))[_0x3d26('0x4')];var BPromise=require('bluebird');var rs=require(_0x3d26('0x5'));var sox=require(_0x3d26('0x6'));var rp=require(_0x3d26('0x7'));var util=require(_0x3d26('0x8'));var querystring=require(_0x3d26('0x9'));var tts=require(_0x3d26('0xa'));var apiai=require('apiai-promise');var md5=require('md5');var google=require('./google');var aws=require(_0x3d26('0xb'));var tilde=require(_0x3d26('0xc'));var sestek=require('./sestek');var logger=require(_0x3d26('0xd'))(_0x3d26('0xe'));var ISPEECH_API=_0x3d26('0xf');function downloadFile(_0x535a8a,_0x41d52b){return new BPromise(function(_0x487d7b,_0x34f351){var _0x159aed=urlParse(_0x535a8a);var _0x9f3bfc=_0x159aed[_0x3d26('0x10')]===_0x3d26('0x11')?https:http;var _0x4d8977={'host':_0x159aed[_0x3d26('0x12')],'path':_0x159aed['path'],'headers':{'user-agent':_0x3d26('0x13')}};_0x9f3bfc[_0x3d26('0x14')](_0x4d8977,function(_0x2804f2){if(_0x2804f2['statusCode']!==0xc8){logger[_0x3d26('0x15')](_0x3d26('0x16')+_0x535a8a+_0x3d26('0x17')+_0x2804f2[_0x3d26('0x18')]+'\x20('+_0x2804f2[_0x3d26('0x19')]+')');_0x34f351(new Error(_0x3d26('0x16')+_0x535a8a+_0x3d26('0x17')+_0x2804f2[_0x3d26('0x18')]+'\x20('+_0x2804f2['statusMessage']+')'));return;}var _0x2ce8dd=fs[_0x3d26('0x1a')](_0x41d52b);_0x2ce8dd['on'](_0x3d26('0x1b'),function(){logger[_0x3d26('0x1c')]('finish\x20download\x20file');_0x2ce8dd['close'](_0x487d7b);});_0x2ce8dd['on'](_0x3d26('0x15'),function(_0x10267c){fs[_0x3d26('0x1d')](_0x41d52b);logger[_0x3d26('0x15')]('download\x20error',_0x10267c);_0x34f351(_0x10267c);});_0x2804f2[_0x3d26('0x1e')](_0x2ce8dd);})['on'](_0x3d26('0x15'),function(_0x4bc493){logger[_0x3d26('0x15')](_0x4bc493);_0x34f351(_0x4bc493);})[_0x3d26('0x1f')]();});}function uploadFile(_0x51a423){return new BPromise(function(_0x2b4443,_0x2d88fe){var _0x17857f=urlParse(_0x51a423);var _0x8497a8=_0x17857f[_0x3d26('0x10')]===_0x3d26('0x11')?https:http;var _0x19d5e9={'host':_0x17857f[_0x3d26('0x12')],'path':_0x17857f['path'],'headers':{'user-agent':_0x3d26('0x13')}};_0x8497a8[_0x3d26('0x14')](_0x19d5e9,function(_0x13bf15){if(_0x13bf15[_0x3d26('0x18')]!==0xc8){_0x2d88fe(new Error('request\x20to\x20'+_0x51a423+'\x20failed,\x20status\x20code\x20=\x20'+_0x13bf15[_0x3d26('0x18')]+'\x20('+_0x13bf15['statusMessage']+')'));return;}var _0x215c9b='';_0x13bf15['on']('data',function(_0x3b1e9a){_0x215c9b+=_0x3b1e9a;});_0x13bf15['on']('end',function(){_0x2b4443(_0x215c9b);});})['on']('error',function(_0x3b6538){_0x2d88fe(_0x3b6538);})['end']();});}function convertFile(_0x11c752,_0x3456be){return new BPromise(function(_0x278165,_0x3a2991){var _0x5da42d=sox[_0x3d26('0x20')](_0x11c752,_0x3456be,{'sampleRate':0x1f40,'format':_0x3d26('0x21'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x5da42d['on'](_0x3d26('0x15'),function(_0x18f954){logger['error'](_0x3d26('0x22'),_0x18f954);_0x3a2991(_0x18f954);});_0x5da42d['on']('end',function(){logger[_0x3d26('0x1c')](_0x3d26('0x23'));_0x278165();});_0x5da42d[_0x3d26('0x24')]();});}function base64Decode(_0x29790c,_0x11f826){var _0x139800=path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs[_0x3d26('0x27')](0x4)+_0x3d26('0x28'));fs[_0x3d26('0x29')](_0x139800,_0x29790c,'base64');return convertFile(_0x139800,_0x11f826)['then'](function(){try{fs['unlink'](_0x139800);fs[_0x3d26('0x2a')](_0x11f826,'777');}catch(_0x137050){logger[_0x3d26('0x15')](_0x137050);}return _0x11f826['split']('.')[0x0];});}function base64Encode(_0xe75595){var _0xbb4321=fs[_0x3d26('0x2b')](_0xe75595);return new Buffer(_0xbb4321)[_0x3d26('0x2c')](_0x3d26('0x2d'));}exports[_0x3d26('0x2e')]=function(_0x1d2d82,_0x573ffb,_0xa886ca,_0x5e3bac,_0x4c75aa,_0x558040){var _0x1666fc,_0x23a642;var _0x1c18fb='https://texttospeech.googleapis.com/v1/';var _0x35926e=_0x3d26('0x2f')+_0x1d2d82;var _0x33891f={};if(_0x573ffb===_0x3d26('0x30')){_0x33891f[_0x3d26('0x31')]={'ssml':_0xa886ca};}else{_0x33891f[_0x3d26('0x31')]={'text':_0xa886ca};};_0x33891f[_0x3d26('0x32')]={'languageCode':_0x5e3bac,'ssmlGender':_0x4c75aa};_0x33891f[_0x3d26('0x33')]={'audioEncoding':_0x3d26('0x34'),'sampleRateHertz':0x1f40};var _0x25866b={'url':_0x1c18fb+_0x3d26('0x35')+_0x35926e,'method':_0x3d26('0x36'),'json':!![],'body':_0x33891f};return rp(_0x25866b)[_0x3d26('0x37')](function(_0x291367){return new BPromise(function(_0x234cd3,_0x286af5){_0x1666fc=path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs[_0x3d26('0x27')](0x4)+_0x3d26('0x38'));var _0x580160=Buffer[_0x3d26('0x39')](_0x291367[_0x3d26('0x3a')],_0x3d26('0x2d'));return fs[_0x3d26('0x3b')](_0x1666fc,_0x580160,function(_0x355a82){_0x286af5(_0x355a82);},function(_0x367a8f){fs[_0x3d26('0x2a')](_0x1666fc,'777');_0x234cd3(_0x367a8f);});});})[_0x3d26('0x37')](function(_0x1d036f){_0x23a642=path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs[_0x3d26('0x27')](0x4)+_0x3d26('0x28'));return convertFile(_0x1666fc,_0x23a642);})[_0x3d26('0x37')](function(){try{fs[_0x3d26('0x1d')](_0x1666fc);fs[_0x3d26('0x2a')](_0x23a642,_0x3d26('0x3c'));}catch(_0x18bad9){logger[_0x3d26('0x15')](_0x18bad9);}logger[_0x3d26('0x1c')](_0x3d26('0x3d'),_0x23a642['split']('.')[0x0]);return _0x23a642[_0x3d26('0x3e')]('.')[0x0];});};exports['googleTTS']=function(_0x175e7d,_0x4dd4af){var _0x5ad9d2,_0x2a3372;return tts(_0x175e7d,_0x4dd4af||'en',0x1)[_0x3d26('0x37')](function(_0xdbe728){logger[_0x3d26('0x1c')](_0xdbe728);_0x5ad9d2=path['resolve'](__dirname,'tmp',rs['generate'](0x4)+_0x3d26('0x38'));return downloadFile(_0xdbe728,_0x5ad9d2);})['then'](function(){_0x2a3372=path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs['generate'](0x4)+_0x3d26('0x28'));return convertFile(_0x5ad9d2,_0x2a3372);})[_0x3d26('0x37')](function(){try{fs[_0x3d26('0x1d')](_0x5ad9d2);fs['chmodSync'](_0x2a3372,_0x3d26('0x3c'));}catch(_0x328e4c){logger['error'](_0x328e4c);}logger[_0x3d26('0x1c')](_0x3d26('0x3f'),_0x2a3372['split']('.')[0x0]);return _0x2a3372[_0x3d26('0x3e')]('.')[0x0];});};exports[_0x3d26('0x40')]=function(_0x268d78,_0x39ddfa,_0x13b60d){return google[_0x3d26('0x41')](_0x268d78,_0x39ddfa,_0x13b60d)[_0x3d26('0x37')](function(_0x146e86){logger[_0x3d26('0x1c')](_0x146e86[_0x3d26('0x42')]);return rp(_0x146e86);})[_0x3d26('0x37')](function(_0x4374c1){var _0x5b9e9a='';var _0x5104ef=0x0;try{fs['unlink'](_0x268d78);}catch(_0x532bf8){logger['error'](_0x532bf8);}if(_0x4374c1&&_0x4374c1[_0x3d26('0x43')]){_0x5b9e9a=_0x4374c1['results'][_0x3d26('0x44')](function(_0x1dc9e4){return _0x1dc9e4&&_0x1dc9e4[_0x3d26('0x45')][0x0]&&_0x1dc9e4[_0x3d26('0x45')][0x0][_0x3d26('0x46')]?_0x1dc9e4[_0x3d26('0x45')][0x0]['transcript']:'';})[_0x3d26('0x47')]('\x0a');_0x5104ef=_0x4374c1[_0x3d26('0x43')]['map'](function(_0x16e4a6){return _0x16e4a6&&_0x16e4a6['alternatives'][0x0]&&_0x16e4a6[_0x3d26('0x45')][0x0][_0x3d26('0x48')]?_0x16e4a6['alternatives'][0x0][_0x3d26('0x48')]:0x0;})[_0x3d26('0x47')]('\x0a');}logger[_0x3d26('0x1c')](_0x3d26('0x49'),_0x5b9e9a);logger[_0x3d26('0x1c')](_0x3d26('0x4a'),_0x5104ef);return{'transcript':_0x5b9e9a,'confidence':_0x5104ef};})[_0x3d26('0x4b')](function(_0x4a841d){logger[_0x3d26('0x15')](_0x3d26('0x4c'),_0x4a841d[_0x3d26('0x18')],_0x4a841d['name'],_0x4a841d[_0x3d26('0x4d')]);});};exports[_0x3d26('0x4e')]=function(_0x509cd1,_0x2b7c65,_0x5896de,_0x6c37fd){var _0x591bd7=apiai(_0x2b7c65,{'language':_0x6c37fd||'en'});return _0x591bd7[_0x3d26('0x4f')](_0x5896de,{'sessionId':md5(_0x509cd1)})[_0x3d26('0x37')](function(_0x2e6eb2){logger[_0x3d26('0x1c')](JSON['stringify'](_0x2e6eb2));return{'source':_0x2e6eb2[_0x3d26('0x50')]['source'],'resolvedQuery':_0x2e6eb2[_0x3d26('0x50')][_0x3d26('0x51')],'action':_0x2e6eb2['result'][_0x3d26('0x52')],'actionIncomplete':_0x2e6eb2[_0x3d26('0x50')][_0x3d26('0x53')],'speech':_0x2e6eb2[_0x3d26('0x50')][_0x3d26('0x54')][_0x3d26('0x55')],'score':_0x2e6eb2[_0x3d26('0x50')][_0x3d26('0x56')],'statusCode':_0x2e6eb2['status'][_0x3d26('0x57')],'endConversation':_0x2e6eb2[_0x3d26('0x50')][_0x3d26('0x58')][_0x3d26('0x59')]||![],'isFallbackIntent':_0x2e6eb2[_0x3d26('0x50')][_0x3d26('0x58')]['isFallbackIntent']};});};exports[_0x3d26('0x5a')]=function(_0x22eb92,_0x2a75e1,_0x3e4e1a,_0x4a428b){return tilde[_0x3d26('0x41')](_0x22eb92,_0x2a75e1,_0x3e4e1a,_0x4a428b)[_0x3d26('0x37')](function(_0x15277e){try{fs[_0x3d26('0x1d')](_0x22eb92);}catch(_0x4615a1){logger[_0x3d26('0x15')](_0x4615a1);}logger[_0x3d26('0x1c')](_0x3d26('0x5b'),_0x15277e['transcript']);logger['info'](_0x3d26('0x5c'),_0x15277e[_0x3d26('0x48')]);return _0x15277e;});};exports[_0x3d26('0x5d')]=function(_0x1110ce,_0x31a754,_0x41c0c6,_0x1a16f8,_0x896ab5,_0x130c31){var _0x4b29e9=path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs[_0x3d26('0x27')](0x4)+_0x3d26('0x38'));var _0x3b11fc;return aws[_0x3d26('0x5e')](_0x1110ce,_0x31a754,_0x41c0c6,_0x1a16f8,_0x896ab5,_0x130c31,_0x4b29e9)['then'](function(){_0x3b11fc=path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs[_0x3d26('0x27')](0x4)+_0x3d26('0x28'));return convertFile(_0x4b29e9,_0x3b11fc);})[_0x3d26('0x37')](function(){try{fs['unlink'](_0x4b29e9);fs[_0x3d26('0x2a')](_0x3b11fc,_0x3d26('0x3c'));}catch(_0x132882){logger['error'](_0x132882);}return _0x3b11fc[_0x3d26('0x3e')]('.')[0x0];});};exports[_0x3d26('0x5f')]=function(_0x1e43d2,_0x265688,_0xd6c174,_0x3ee836,_0x1a59ee,_0x2c5f38){return aws[_0x3d26('0x60')](_0x1e43d2,_0x265688,_0xd6c174,_0x3ee836,_0x1a59ee,_0x2c5f38)[_0x3d26('0x37')](function(_0x62ac0a){logger[_0x3d26('0x1c')](JSON[_0x3d26('0x61')](_0x62ac0a));return _0x62ac0a;});};exports[_0x3d26('0x62')]=function(_0x24ef45,_0x5034f1,_0x254705,_0x2e77de){var _0x2be51d=util[_0x3d26('0x63')]('%s?apikey=%s&action=convert&text=%s&voice=%s&speed=%s&format=mp3',ISPEECH_API,_0x24ef45,encodeURIComponent(_0x5034f1),_0x254705,_0x2e77de);var _0x3efa39=path['resolve'](__dirname,_0x3d26('0x26'),rs[_0x3d26('0x27')](0x4)+_0x3d26('0x38'));var _0x2e675b;return downloadFile(_0x2be51d,_0x3efa39)[_0x3d26('0x37')](function(){_0x2e675b=path['resolve'](__dirname,'tmp',rs['generate'](0x4)+_0x3d26('0x28'));return convertFile(_0x3efa39,_0x2e675b);})[_0x3d26('0x37')](function(){try{fs['unlink'](_0x3efa39);fs['chmodSync'](_0x2e675b,_0x3d26('0x3c'));}catch(_0x22e7a3){logger[_0x3d26('0x15')](_0x22e7a3);}return _0x2e675b['split']('.')[0x0];});};exports[_0x3d26('0x64')]=function(_0xfb975c,_0x30eb9d,_0x40b880,_0x418bd2){var _0x52fdfa=util[_0x3d26('0x63')](_0x3d26('0x65'),ISPEECH_API,_0x30eb9d,_0x40b880,base64Encode(_0xfb975c),_0x418bd2?util[_0x3d26('0x63')](_0x3d26('0x66'),encodeURIComponent(_0x418bd2)):'freeform=3');return uploadFile(_0x52fdfa)[_0x3d26('0x37')](function(_0x4af539){return querystring[_0x3d26('0x4')](_0x4af539);});};exports[_0x3d26('0x67')]=function(_0x47ba60,_0x37a066){return sestek['nda'](_0x47ba60,_0x37a066)[_0x3d26('0x37')](function(_0x35a0d0){logger[_0x3d26('0x1c')](JSON[_0x3d26('0x61')](_0x35a0d0));var _0x14f510={'speech':_0x35a0d0[_0x3d26('0x68')],'action':_0x35a0d0['channelData']?_0x35a0d0[_0x3d26('0x69')]['CustomAction']:undefined,'actiondata':_0x35a0d0['channelData']?_0x35a0d0['channelData'][_0x3d26('0x6a')]:undefined};if(_0x35a0d0[_0x3d26('0x69')]&&_0x35a0d0['channelData'][_0x3d26('0x6b')]){return base64Decode(_0x35a0d0[_0x3d26('0x69')][_0x3d26('0x6b')][_0x3d26('0x6c')],path[_0x3d26('0x25')](__dirname,_0x3d26('0x26'),rs['generate'](0x4)+_0x3d26('0x28')))[_0x3d26('0x37')](function(_0x510d82){_0x14f510[_0x3d26('0x6d')]=_0x510d82;return _0x14f510;});}return _0x14f510;});};exports[_0x3d26('0x6e')]=function(){return __dirname;};
\ No newline at end of file
+var _0x2857=['length','lang\x20\x22','\x22\x20might\x20not\x20exist','.wav','asr','uri','results','alternatives','transcript','join','map','confidence','googleASR\x20transcription','googleASR\x20confidence','name','message','googleDialogflow','result','source','resolvedQuery','action','fulfillment','speech','metadata','endConversation','googleDialogflowV2','SessionsClient','sessionPath','detectIntent','queryResult','allRequiredParamsPresent','diagnosticInfo','fields','end_conversation','boolValue','fulfillmentText','intent','displayName','languageCode','queryText','responseId','intentDetectionConfidence','tildeASR','Tilde\x20ASR\x20transcription','Tilde\x20ASR\x20confidence','.mp3','awsLex','lex','ispeechTTS','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','freeform=3','sestekNDA','nda','channelData','CustomAction','CustomActionData','AudioFromTts','Data','audiofile','dirName','apiai-promise','bluebird','http','https','md5','path','randomstring','sox','google-tts-api','url','parse','./aws','./google','./sestek','./tilde','../../../config/logger','agi','protocol','https:','host','WHAT_EVER','get','statusCode','error','request\x20to\x20','\x20failed,\x20status\x20code\x20=\x20','statusMessage','createWriteStream','finish','info','finish\x20download\x20file','close','unlink','download\x20error','pipe','end','transcode','wav','finish\x20to\x20convert','start','tmp','generate','writeFileSync','base64','then','googleCloudTTS','ssml','input','voice','audioConfig','text:synthesize','POST','resolve','audioContent','chmodSync','777','googleCloudTTS\x20path','split','googleTTS','https://translate.google.com/_/TranslateWebserverUi/data/batchexecute','application/x-www-form-urlencoded','stringify','jQ1olc','null','slice','data'];(function(_0x35125a,_0x1121ef){var _0x3aa732=function(_0x5154ae){while(--_0x5154ae){_0x35125a['push'](_0x35125a['shift']());}};_0x3aa732(++_0x1121ef);}(_0x2857,0xc2));var _0x7285=function(_0x3cf58d,_0x394240){_0x3cf58d=_0x3cf58d-0x0;var _0x284a3f=_0x2857[_0x3cf58d];return _0x284a3f;};'use strict';var apiai=require(_0x7285('0x0'));var BPromise=require(_0x7285('0x1'));var dialogflow=require('dialogflow');var fs=require('fs');var http=require(_0x7285('0x2'));var https=require(_0x7285('0x3'));var md5=require(_0x7285('0x4'));var path=require(_0x7285('0x5'));var querystring=require('querystring');var rp=require('request-promise');var rs=require(_0x7285('0x6'));var sox=require(_0x7285('0x7'));var tts=require(_0x7285('0x8'));var urlParse=require(_0x7285('0x9'))[_0x7285('0xa')];var util=require('util');var aws=require(_0x7285('0xb'));var google=require(_0x7285('0xc'));var sestek=require(_0x7285('0xd'));var tilde=require(_0x7285('0xe'));var logger=require(_0x7285('0xf'))(_0x7285('0x10'));var ISPEECH_API='https://api.ispeech.org/api/rest';function downloadFile(_0x49aad2,_0x54d62b){return new BPromise(function(_0x37192b,_0x1934ce){var _0x46f8cb=urlParse(_0x49aad2);var _0x148f39=_0x46f8cb[_0x7285('0x11')]===_0x7285('0x12')?https:http;var _0x1816be={'host':_0x46f8cb[_0x7285('0x13')],'path':_0x46f8cb['path'],'headers':{'user-agent':_0x7285('0x14')}};_0x148f39[_0x7285('0x15')](_0x1816be,function(_0x325de5){if(_0x325de5[_0x7285('0x16')]!==0xc8){logger[_0x7285('0x17')](_0x7285('0x18')+_0x49aad2+_0x7285('0x19')+_0x325de5[_0x7285('0x16')]+'\x20('+_0x325de5[_0x7285('0x1a')]+')');_0x1934ce(new Error(_0x7285('0x18')+_0x49aad2+_0x7285('0x19')+_0x325de5[_0x7285('0x16')]+'\x20('+_0x325de5[_0x7285('0x1a')]+')'));return;}var _0x2ffa6e=fs[_0x7285('0x1b')](_0x54d62b);_0x2ffa6e['on'](_0x7285('0x1c'),function(){logger[_0x7285('0x1d')](_0x7285('0x1e'));_0x2ffa6e[_0x7285('0x1f')](_0x37192b);});_0x2ffa6e['on'](_0x7285('0x17'),function(_0x94fdf8){fs[_0x7285('0x20')](_0x54d62b);logger[_0x7285('0x17')](_0x7285('0x21'),_0x94fdf8);_0x1934ce(_0x94fdf8);});_0x325de5[_0x7285('0x22')](_0x2ffa6e);})['on'](_0x7285('0x17'),function(_0x444bfe){logger['error'](_0x444bfe);_0x1934ce(_0x444bfe);})[_0x7285('0x23')]();});}function uploadFile(_0x16810d){return new BPromise(function(_0x26a7a9,_0x149f8e){var _0x55d46b=urlParse(_0x16810d);var _0x349fb8=_0x55d46b['protocol']===_0x7285('0x12')?https:http;var _0x204ad5={'host':_0x55d46b[_0x7285('0x13')],'path':_0x55d46b[_0x7285('0x5')],'headers':{'user-agent':_0x7285('0x14')}};_0x349fb8['get'](_0x204ad5,function(_0x511d96){if(_0x511d96['statusCode']!==0xc8){_0x149f8e(new Error('request\x20to\x20'+_0x16810d+_0x7285('0x19')+_0x511d96[_0x7285('0x16')]+'\x20('+_0x511d96[_0x7285('0x1a')]+')'));return;}var _0x1af8af='';_0x511d96['on']('data',function(_0x45c33e){_0x1af8af+=_0x45c33e;});_0x511d96['on']('end',function(){_0x26a7a9(_0x1af8af);});})['on'](_0x7285('0x17'),function(_0x5b8f90){_0x149f8e(_0x5b8f90);})[_0x7285('0x23')]();});}function convertFile(_0x4f304c,_0x4ab213){return new BPromise(function(_0x2d6c85,_0x4da0e8){var _0x34f165=sox[_0x7285('0x24')](_0x4f304c,_0x4ab213,{'sampleRate':0x1f40,'format':_0x7285('0x25'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x34f165['on']('error',function(_0x492fbe){logger[_0x7285('0x17')]('error\x20convert',_0x492fbe);_0x4da0e8(_0x492fbe);});_0x34f165['on'](_0x7285('0x23'),function(){logger['info'](_0x7285('0x26'));_0x2d6c85();});_0x34f165[_0x7285('0x27')]();});}function base64Decode(_0xaa928d,_0x220226){var _0x8fa72e=path['resolve'](__dirname,_0x7285('0x28'),rs[_0x7285('0x29')](0x4)+'.wav');fs[_0x7285('0x2a')](_0x8fa72e,_0xaa928d,_0x7285('0x2b'));return convertFile(_0x8fa72e,_0x220226)[_0x7285('0x2c')](function(){try{fs[_0x7285('0x20')](_0x8fa72e);fs['chmodSync'](_0x220226,'777');}catch(_0x28977a){logger['error'](_0x28977a);}return _0x220226['split']('.')[0x0];});}function base64Encode(_0x498640){var _0x86533=fs['readFileSync'](_0x498640);return new Buffer(_0x86533)['toString'](_0x7285('0x2b'));}exports[_0x7285('0x2d')]=function(_0x4b7c93,_0x58214a,_0x5cb7d9,_0x2be5db,_0x32740d,_0x421d83){var _0x2876fd,_0x3df34e;var _0x5c9b4e='https://texttospeech.googleapis.com/v1/';var _0x2c8ec9='?key='+_0x4b7c93;var _0x208e41={};if(_0x58214a===_0x7285('0x2e')){_0x208e41[_0x7285('0x2f')]={'ssml':_0x5cb7d9};}else{_0x208e41[_0x7285('0x2f')]={'text':_0x5cb7d9};};_0x208e41[_0x7285('0x30')]={'languageCode':_0x2be5db,'ssmlGender':_0x32740d};_0x208e41[_0x7285('0x31')]={'audioEncoding':'MP3','sampleRateHertz':0x1f40};var _0x52bddc={'url':_0x5c9b4e+_0x7285('0x32')+_0x2c8ec9,'method':_0x7285('0x33'),'json':!![],'body':_0x208e41};return rp(_0x52bddc)[_0x7285('0x2c')](function(_0x2e71f3){return new BPromise(function(_0x1bb9f2,_0x232d0e){_0x2876fd=path[_0x7285('0x34')](__dirname,_0x7285('0x28'),rs['generate'](0x4)+'.mp3');var _0x27e221=Buffer['from'](_0x2e71f3[_0x7285('0x35')],'base64');return fs['writeFile'](_0x2876fd,_0x27e221,function(_0x512174){_0x232d0e(_0x512174);},function(_0x330d32){fs[_0x7285('0x36')](_0x2876fd,_0x7285('0x37'));_0x1bb9f2(_0x330d32);});});})[_0x7285('0x2c')](function(_0x50cc00){_0x3df34e=path['resolve'](__dirname,'tmp',rs['generate'](0x4)+'.wav');return convertFile(_0x2876fd,_0x3df34e);})[_0x7285('0x2c')](function(){try{fs['unlink'](_0x2876fd);fs[_0x7285('0x36')](_0x3df34e,_0x7285('0x37'));}catch(_0x41a49e){logger[_0x7285('0x17')](_0x41a49e);}logger[_0x7285('0x1d')](_0x7285('0x38'),_0x3df34e[_0x7285('0x39')]('.')[0x0]);return _0x3df34e[_0x7285('0x39')]('.')[0x0];});};exports[_0x7285('0x3a')]=function(_0x3d28aa,_0x582bd4){var _0xa35cb7=_0x7285('0x3b');var _0x28f234,_0x551bb4;var _0x2f260d;var _0x2bb86f={'encoding':'utf8','method':_0x7285('0x33'),'timeout':0x2710,'url':_0xa35cb7,'headers':{'Content-Type':_0x7285('0x3c')},'body':'f.req='+encodeURIComponent(JSON[_0x7285('0x3d')]([[[_0x7285('0x3e'),JSON['stringify']([_0x3d28aa,_0x582bd4||'en',![],_0x7285('0x3f')]),null,'generic']]]))};return rp(_0x2bb86f)[_0x7285('0x2c')](function(_0x175100){try{_0x2f260d=eval(_0x175100[_0x7285('0x40')](0x5))[0x0][0x2];}catch(_0xcf6d2d){throw new Error('parse\x20response\x20failed:\x0a'+_0x175100[_0x7285('0x41')]);}if(!_0x2f260d){if(_0x3d28aa[_0x7285('0x42')]>0xc8){throw new Error('text\x20length\x20limit\x20reached');}else{throw new Error(_0x7285('0x43')+_0x582bd4+_0x7285('0x44'));}}try{_0x2f260d=eval(_0x2f260d)[0x0];}catch(_0x4645b8){throw new Error('parse\x20response\x20failed:\x0a'+res[_0x7285('0x41')]);}const _0x369996=_0x2f260d;_0x28f234=path[_0x7285('0x34')](__dirname,_0x7285('0x28'),rs[_0x7285('0x29')](0x4)+'.mp3');fs[_0x7285('0x2a')](_0x28f234,_0x2f260d,{'encoding':_0x7285('0x2b')});_0x551bb4=path['resolve'](__dirname,'tmp',rs[_0x7285('0x29')](0x4)+_0x7285('0x45'));return convertFile(_0x28f234,_0x551bb4);})['then'](function(){try{fs['unlink'](_0x28f234);fs[_0x7285('0x36')](_0x551bb4,_0x7285('0x37'));}catch(_0x7febab){logger[_0x7285('0x17')](_0x7febab);}logger['info']('goggleTTS\x20path',_0x551bb4[_0x7285('0x39')]('.')[0x0]);return _0x551bb4[_0x7285('0x39')]('.')[0x0];});};exports['googleASR']=function(_0xad3fb4,_0x341d83,_0x5ed5cc){return google[_0x7285('0x46')](_0xad3fb4,_0x341d83,_0x5ed5cc)[_0x7285('0x2c')](function(_0x50e4cc){logger[_0x7285('0x1d')](_0x50e4cc[_0x7285('0x47')]);return rp(_0x50e4cc);})[_0x7285('0x2c')](function(_0x16c115){var _0x5d39de='';var _0x37dfeb=0x0;try{fs[_0x7285('0x20')](_0xad3fb4);}catch(_0x1a6e27){logger[_0x7285('0x17')](_0x1a6e27);}if(_0x16c115&&_0x16c115[_0x7285('0x48')]){_0x5d39de=_0x16c115[_0x7285('0x48')]['map'](function(_0x24d5e5){return _0x24d5e5&&_0x24d5e5[_0x7285('0x49')][0x0]&&_0x24d5e5[_0x7285('0x49')][0x0][_0x7285('0x4a')]?_0x24d5e5[_0x7285('0x49')][0x0][_0x7285('0x4a')]:'';})[_0x7285('0x4b')]('\x0a');_0x37dfeb=_0x16c115[_0x7285('0x48')][_0x7285('0x4c')](function(_0xc1d134){return _0xc1d134&&_0xc1d134[_0x7285('0x49')][0x0]&&_0xc1d134[_0x7285('0x49')][0x0][_0x7285('0x4d')]?_0xc1d134[_0x7285('0x49')][0x0][_0x7285('0x4d')]:0x0;})[_0x7285('0x4b')]('\x0a');}logger[_0x7285('0x1d')](_0x7285('0x4e'),_0x5d39de);logger[_0x7285('0x1d')](_0x7285('0x4f'),_0x37dfeb);return{'transcript':_0x5d39de,'confidence':_0x37dfeb};})['catch'](function(_0x2e6e80){logger[_0x7285('0x17')]('[%s]\x20%s:%s',_0x2e6e80[_0x7285('0x16')],_0x2e6e80[_0x7285('0x50')],_0x2e6e80[_0x7285('0x51')]);});};exports[_0x7285('0x52')]=function(_0x2f63f3,_0x18d7f4,_0x5e2f97,_0x1d0189){var _0x74069f=apiai(_0x18d7f4,{'language':_0x1d0189||'en'});return _0x74069f['textRequest'](_0x5e2f97,{'sessionId':md5(_0x2f63f3)})[_0x7285('0x2c')](function(_0x4f41ef){logger[_0x7285('0x1d')](JSON[_0x7285('0x3d')](_0x4f41ef));return{'source':_0x4f41ef[_0x7285('0x53')][_0x7285('0x54')],'resolvedQuery':_0x4f41ef[_0x7285('0x53')][_0x7285('0x55')],'action':_0x4f41ef[_0x7285('0x53')][_0x7285('0x56')],'actionIncomplete':_0x4f41ef['result']['actionIncomplete'],'speech':_0x4f41ef['result'][_0x7285('0x57')][_0x7285('0x58')],'score':_0x4f41ef[_0x7285('0x53')]['score'],'statusCode':_0x4f41ef['status']['code'],'endConversation':_0x4f41ef[_0x7285('0x53')][_0x7285('0x59')][_0x7285('0x5a')]||![],'isFallbackIntent':_0x4f41ef[_0x7285('0x53')][_0x7285('0x59')]['isFallbackIntent']};});};exports[_0x7285('0x5b')]=function(_0x15dcdd,_0x1ad794,_0x5bb8ac,_0x1abc52,_0x37c7e2,_0x5196b2){var _0x51f5f9=_0x1abc52['replace'](/\\n/g,'\x0a');var _0x36ad74={'credentials':{'private_key':_0x51f5f9,'client_email':_0x5bb8ac}};var _0xe84918=new dialogflow[(_0x7285('0x5c'))](_0x36ad74);var _0x390ee2=_0xe84918[_0x7285('0x5d')](_0x1ad794,md5(_0x15dcdd));var _0x3d45f5={'session':_0x390ee2,'queryInput':{'text':{'text':_0x37c7e2,'languageCode':_0x5196b2}}};return _0xe84918[_0x7285('0x5e')](_0x3d45f5)[_0x7285('0x2c')](function(_0x358265){if(_0x358265&&_0x358265[_0x7285('0x42')]){logger[_0x7285('0x1d')]('Dialogflow\x20V2\x20response:',JSON[_0x7285('0x3d')](_0x358265));var _0x920208=_0x358265[0x0];if(_0x920208){var _0x2d09ff={'action':_0x920208[_0x7285('0x5f')][_0x7285('0x56')],'allRequiredParamsPresent':_0x920208[_0x7285('0x5f')][_0x7285('0x60')],'endConversation':_0x920208[_0x7285('0x5f')][_0x7285('0x61')]&&_0x920208[_0x7285('0x5f')][_0x7285('0x61')][_0x7285('0x62')]?_0x920208[_0x7285('0x5f')]['diagnosticInfo'][_0x7285('0x62')][_0x7285('0x63')][_0x7285('0x64')]:![],'fulfillmentText':_0x920208['queryResult'][_0x7285('0x65')],'intentName':_0x920208[_0x7285('0x5f')][_0x7285('0x66')][_0x7285('0x50')],'intentDisplayName':_0x920208['queryResult']['intent'][_0x7285('0x67')],'isFallbackIntent':_0x920208[_0x7285('0x5f')]['intent']['isFallback'],'languageCode':_0x920208['queryResult'][_0x7285('0x68')],'queryText':_0x920208[_0x7285('0x5f')][_0x7285('0x69')],'responseId':_0x920208[_0x7285('0x6a')],'score':_0x920208['queryResult'][_0x7285('0x6b')],'speech':_0x920208['queryResult'][_0x7285('0x65')],'providerResponse':JSON[_0x7285('0x3d')](_0x358265)};return _0x2d09ff;}}});};exports[_0x7285('0x6c')]=function(_0x2e602e,_0x1b1c98,_0x2acc81,_0x48c534){return tilde['asr'](_0x2e602e,_0x1b1c98,_0x2acc81,_0x48c534)[_0x7285('0x2c')](function(_0x359dd0){try{fs['unlink'](_0x2e602e);}catch(_0x1ceaf8){logger[_0x7285('0x17')](_0x1ceaf8);}logger[_0x7285('0x1d')](_0x7285('0x6d'),_0x359dd0[_0x7285('0x4a')]);logger[_0x7285('0x1d')](_0x7285('0x6e'),_0x359dd0[_0x7285('0x4d')]);return _0x359dd0;});};exports['awsPolly']=function(_0xbaa921,_0x446440,_0x48515d,_0x381458,_0x853c4c,_0x3e992a){var _0x5e244d=path[_0x7285('0x34')](__dirname,_0x7285('0x28'),rs[_0x7285('0x29')](0x4)+_0x7285('0x6f'));var _0x4e7d95;return aws['polly'](_0xbaa921,_0x446440,_0x48515d,_0x381458,_0x853c4c,_0x3e992a,_0x5e244d)[_0x7285('0x2c')](function(){_0x4e7d95=path[_0x7285('0x34')](__dirname,_0x7285('0x28'),rs['generate'](0x4)+'.wav');return convertFile(_0x5e244d,_0x4e7d95);})['then'](function(){try{fs[_0x7285('0x20')](_0x5e244d);fs[_0x7285('0x36')](_0x4e7d95,_0x7285('0x37'));}catch(_0x3a6633){logger['error'](_0x3a6633);}return _0x4e7d95[_0x7285('0x39')]('.')[0x0];});};exports[_0x7285('0x70')]=function(_0x6e2f72,_0x108c83,_0x2119e4,_0x58bb59,_0x5186ac,_0x54ddd8){return aws[_0x7285('0x71')](_0x6e2f72,_0x108c83,_0x2119e4,_0x58bb59,_0x5186ac,_0x54ddd8)[_0x7285('0x2c')](function(_0x5cc2ed){logger[_0x7285('0x1d')](JSON[_0x7285('0x3d')](_0x5cc2ed));return _0x5cc2ed;});};exports[_0x7285('0x72')]=function(_0x3c3e72,_0x26b016,_0x5b0efd,_0x515a7e){var _0x1ca771=util[_0x7285('0x73')](_0x7285('0x74'),ISPEECH_API,_0x3c3e72,encodeURIComponent(_0x26b016),_0x5b0efd,_0x515a7e);var _0xa44906=path[_0x7285('0x34')](__dirname,'tmp',rs[_0x7285('0x29')](0x4)+_0x7285('0x6f'));var _0x33f2d0;return downloadFile(_0x1ca771,_0xa44906)['then'](function(){_0x33f2d0=path['resolve'](__dirname,'tmp',rs[_0x7285('0x29')](0x4)+_0x7285('0x45'));return convertFile(_0xa44906,_0x33f2d0);})[_0x7285('0x2c')](function(){try{fs[_0x7285('0x20')](_0xa44906);fs['chmodSync'](_0x33f2d0,'777');}catch(_0x1fa723){logger[_0x7285('0x17')](_0x1fa723);}return _0x33f2d0[_0x7285('0x39')]('.')[0x0];});};exports[_0x7285('0x75')]=function(_0xf31e9a,_0x3beb8c,_0x586514,_0x1b2ac1){var _0x2a44de=util['format'](_0x7285('0x76'),ISPEECH_API,_0x3beb8c,_0x586514,base64Encode(_0xf31e9a),_0x1b2ac1?util[_0x7285('0x73')](_0x7285('0x77'),encodeURIComponent(_0x1b2ac1)):_0x7285('0x78'));return uploadFile(_0x2a44de)[_0x7285('0x2c')](function(_0x110a20){return querystring[_0x7285('0xa')](_0x110a20);});};exports[_0x7285('0x79')]=function(_0x16dab9,_0x581199){return sestek[_0x7285('0x7a')](_0x16dab9,_0x581199)[_0x7285('0x2c')](function(_0x57a8c6){logger[_0x7285('0x1d')](JSON[_0x7285('0x3d')](_0x57a8c6));var _0x1ff0c0={'speech':_0x57a8c6['text'],'action':_0x57a8c6[_0x7285('0x7b')]?_0x57a8c6[_0x7285('0x7b')][_0x7285('0x7c')]:undefined,'actiondata':_0x57a8c6[_0x7285('0x7b')]?_0x57a8c6[_0x7285('0x7b')][_0x7285('0x7d')]:undefined};if(_0x57a8c6[_0x7285('0x7b')]&&_0x57a8c6[_0x7285('0x7b')][_0x7285('0x7e')]){return base64Decode(_0x57a8c6[_0x7285('0x7b')]['AudioFromTts'][_0x7285('0x7f')],path[_0x7285('0x34')](__dirname,_0x7285('0x28'),rs[_0x7285('0x29')](0x4)+_0x7285('0x45')))[_0x7285('0x2c')](function(_0x5b630c){_0x1ff0c0[_0x7285('0x80')]=_0x5b630c;return _0x1ff0c0;});}return _0x1ff0c0;});};exports[_0x7285('0x81')]=function(){return __dirname;};
\ No newline at end of file