Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / services / agi / scripts / index.js
index f96fd93..c96a973 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x26f9=['./google','./aws','./tilde','./sestek','https:','WHAT_EVER','get','statusCode','\x20failed,\x20status\x20code\x20=\x20','statusMessage','createWriteStream','finish','info','finish\x20download\x20file','close','error','pipe','end','protocol','host','transcode','wav','resolve','tmp','generate','.wav','writeFileSync','base64','unlink','chmodSync','777','toString','googleCloudTTS','https://texttospeech.googleapis.com/v1/','?key=','ssml','input','voice','audioConfig','MP3','POST','then','.mp3','from','audioContent','writeFile','googleCloudTTS\x20path','googleTTS','goggleTTS\x20path','split','googleASR','asr','uri','results','map','alternatives','transcript','join','confidence','googleASR\x20confidence','catch','name','message','textRequest','stringify','result','resolvedQuery','actionIncomplete','fulfillment','speech','score','status','metadata','endConversation','isFallbackIntent','tildeASR','Tilde\x20ASR\x20confidence','awsPolly','polly','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','sestekNDA','nda','text','channelData','CustomAction','CustomActionData','AudioFromTts','Data','dirName','path','https','url','parse','bluebird','randomstring','sox','request-promise','querystring','google-tts-api','apiai-promise','md5'];(function(_0x5805d7,_0x3d584a){var _0x170fe4=function(_0x3b9b73){while(--_0x3b9b73){_0x5805d7['push'](_0x5805d7['shift']());}};_0x170fe4(++_0x3d584a);}(_0x26f9,0xcc));var _0x926f=function(_0x45fb8f,_0x46da98){_0x45fb8f=_0x45fb8f-0x0;var _0x3d906b=_0x26f9[_0x45fb8f];return _0x3d906b;};'use strict';var fs=require('fs');var path=require(_0x926f('0x0'));var http=require('http');var https=require(_0x926f('0x1'));var urlParse=require(_0x926f('0x2'))[_0x926f('0x3')];var BPromise=require(_0x926f('0x4'));var rs=require(_0x926f('0x5'));var sox=require(_0x926f('0x6'));var rp=require(_0x926f('0x7'));var util=require('util');var querystring=require(_0x926f('0x8'));var tts=require(_0x926f('0x9'));var apiai=require(_0x926f('0xa'));var md5=require(_0x926f('0xb'));var google=require(_0x926f('0xc'));var aws=require(_0x926f('0xd'));var tilde=require(_0x926f('0xe'));var sestek=require(_0x926f('0xf'));var logger=require('../../../config/logger')('agi');var ISPEECH_API='https://api.ispeech.org/api/rest';function downloadFile(_0xe5be3b,_0x47bc6b){return new BPromise(function(_0x20de4d,_0x8d7e3){var _0x40fa25=urlParse(_0xe5be3b);var _0x3d8b32=_0x40fa25['protocol']===_0x926f('0x10')?https:http;var _0x4d5a11={'host':_0x40fa25['host'],'path':_0x40fa25[_0x926f('0x0')],'headers':{'user-agent':_0x926f('0x11')}};_0x3d8b32[_0x926f('0x12')](_0x4d5a11,function(_0x56781d){if(_0x56781d[_0x926f('0x13')]!==0xc8){logger['error']('request\x20to\x20'+_0xe5be3b+_0x926f('0x14')+_0x56781d[_0x926f('0x13')]+'\x20('+_0x56781d['statusMessage']+')');_0x8d7e3(new Error('request\x20to\x20'+_0xe5be3b+_0x926f('0x14')+_0x56781d[_0x926f('0x13')]+'\x20('+_0x56781d[_0x926f('0x15')]+')'));return;}var _0x1e2cca=fs[_0x926f('0x16')](_0x47bc6b);_0x1e2cca['on'](_0x926f('0x17'),function(){logger[_0x926f('0x18')](_0x926f('0x19'));_0x1e2cca[_0x926f('0x1a')](_0x20de4d);});_0x1e2cca['on']('error',function(_0x2c05b4){fs['unlink'](_0x47bc6b);logger[_0x926f('0x1b')]('download\x20error',_0x2c05b4);_0x8d7e3(_0x2c05b4);});_0x56781d[_0x926f('0x1c')](_0x1e2cca);})['on'](_0x926f('0x1b'),function(_0x2eb0b1){logger[_0x926f('0x1b')](_0x2eb0b1);_0x8d7e3(_0x2eb0b1);})[_0x926f('0x1d')]();});}function uploadFile(_0x69a0eb){return new BPromise(function(_0x332415,_0x1d5b69){var _0x16087b=urlParse(_0x69a0eb);var _0x410241=_0x16087b[_0x926f('0x1e')]==='https:'?https:http;var _0x253fc8={'host':_0x16087b[_0x926f('0x1f')],'path':_0x16087b[_0x926f('0x0')],'headers':{'user-agent':'WHAT_EVER'}};_0x410241[_0x926f('0x12')](_0x253fc8,function(_0x41debc){if(_0x41debc[_0x926f('0x13')]!==0xc8){_0x1d5b69(new Error('request\x20to\x20'+_0x69a0eb+'\x20failed,\x20status\x20code\x20=\x20'+_0x41debc[_0x926f('0x13')]+'\x20('+_0x41debc[_0x926f('0x15')]+')'));return;}var _0x3b906a='';_0x41debc['on']('data',function(_0x44d273){_0x3b906a+=_0x44d273;});_0x41debc['on'](_0x926f('0x1d'),function(){_0x332415(_0x3b906a);});})['on']('error',function(_0x47bb70){_0x1d5b69(_0x47bb70);})[_0x926f('0x1d')]();});}function convertFile(_0x46d556,_0x493654){return new BPromise(function(_0x513c5e,_0x2fe43e){var _0x383218=sox[_0x926f('0x20')](_0x46d556,_0x493654,{'sampleRate':0x1f40,'format':_0x926f('0x21'),'channelCount':0x1,'bitRate':0xc0*0x400,'compressionQuality':0x5});_0x383218['on']('error',function(_0x11011b){logger['error']('error\x20convert',_0x11011b);_0x2fe43e(_0x11011b);});_0x383218['on'](_0x926f('0x1d'),function(){logger['info']('finish\x20to\x20convert');_0x513c5e();});_0x383218['start']();});}function base64Decode(_0x453423,_0x45ca96){var _0x18a814=path[_0x926f('0x22')](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+_0x926f('0x25'));fs[_0x926f('0x26')](_0x18a814,_0x453423,_0x926f('0x27'));return convertFile(_0x18a814,_0x45ca96)['then'](function(){try{fs[_0x926f('0x28')](_0x18a814);fs[_0x926f('0x29')](_0x45ca96,_0x926f('0x2a'));}catch(_0x5a02f3){logger[_0x926f('0x1b')](_0x5a02f3);}return _0x45ca96['split']('.')[0x0];});}function base64Encode(_0x3d22d6){var _0x3faa77=fs['readFileSync'](_0x3d22d6);return new Buffer(_0x3faa77)[_0x926f('0x2b')](_0x926f('0x27'));}exports[_0x926f('0x2c')]=function(_0x4ba44c,_0x26b388,_0x4e3225,_0x29d7c7,_0x30c1b1,_0x34c8ee){var _0x36fe2c,_0x5698cc;var _0x85ac84=_0x926f('0x2d');var _0x3a525b=_0x926f('0x2e')+_0x4ba44c;var _0x1acbbd={};if(_0x26b388===_0x926f('0x2f')){_0x1acbbd['input']={'ssml':_0x4e3225};}else{_0x1acbbd[_0x926f('0x30')]={'text':_0x4e3225};};_0x1acbbd[_0x926f('0x31')]={'languageCode':_0x29d7c7,'ssmlGender':_0x30c1b1};_0x1acbbd[_0x926f('0x32')]={'audioEncoding':_0x926f('0x33'),'sampleRateHertz':0x1f40};var _0x3763d6={'url':_0x85ac84+'text:synthesize'+_0x3a525b,'method':_0x926f('0x34'),'json':!![],'body':_0x1acbbd};return rp(_0x3763d6)[_0x926f('0x35')](function(_0x315dcd){return new BPromise(function(_0x4992f6,_0x5546fe){_0x36fe2c=path['resolve'](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+_0x926f('0x36'));var _0x24dc1e=Buffer[_0x926f('0x37')](_0x315dcd[_0x926f('0x38')],'base64');return fs[_0x926f('0x39')](_0x36fe2c,_0x24dc1e,function(_0x4359c2){_0x5546fe(_0x4359c2);},function(_0x10d283){fs[_0x926f('0x29')](_0x36fe2c,_0x926f('0x2a'));_0x4992f6(_0x10d283);});});})[_0x926f('0x35')](function(_0x5c80b7){_0x5698cc=path[_0x926f('0x22')](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+'.wav');return convertFile(_0x36fe2c,_0x5698cc);})[_0x926f('0x35')](function(){try{fs['unlink'](_0x36fe2c);fs[_0x926f('0x29')](_0x5698cc,'777');}catch(_0x1cc4b6){logger[_0x926f('0x1b')](_0x1cc4b6);}logger[_0x926f('0x18')](_0x926f('0x3a'),_0x5698cc['split']('.')[0x0]);return _0x5698cc['split']('.')[0x0];});};exports[_0x926f('0x3b')]=function(_0x3088b7,_0xa9344f){var _0x1dc26e,_0x2f651e;return tts(_0x3088b7,_0xa9344f||'en',0x1)[_0x926f('0x35')](function(_0x3b4e3c){logger['info'](_0x3b4e3c);_0x1dc26e=path[_0x926f('0x22')](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+_0x926f('0x36'));return downloadFile(_0x3b4e3c,_0x1dc26e);})[_0x926f('0x35')](function(){_0x2f651e=path['resolve'](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+'.wav');return convertFile(_0x1dc26e,_0x2f651e);})['then'](function(){try{fs[_0x926f('0x28')](_0x1dc26e);fs['chmodSync'](_0x2f651e,_0x926f('0x2a'));}catch(_0x1f07e5){logger['error'](_0x1f07e5);}logger[_0x926f('0x18')](_0x926f('0x3c'),_0x2f651e[_0x926f('0x3d')]('.')[0x0]);return _0x2f651e[_0x926f('0x3d')]('.')[0x0];});};exports[_0x926f('0x3e')]=function(_0x25705a,_0x576785,_0x51090b){return google[_0x926f('0x3f')](_0x25705a,_0x576785,_0x51090b)[_0x926f('0x35')](function(_0x2da23b){logger[_0x926f('0x18')](_0x2da23b[_0x926f('0x40')]);return rp(_0x2da23b);})[_0x926f('0x35')](function(_0x214c33){var _0x3e5f2d='';var _0x2770c4=0x0;try{fs['unlink'](_0x25705a);}catch(_0x5c65dd){logger[_0x926f('0x1b')](_0x5c65dd);}if(_0x214c33&&_0x214c33[_0x926f('0x41')]){_0x3e5f2d=_0x214c33[_0x926f('0x41')][_0x926f('0x42')](function(_0x3206ce){return _0x3206ce&&_0x3206ce[_0x926f('0x43')][0x0]&&_0x3206ce[_0x926f('0x43')][0x0][_0x926f('0x44')]?_0x3206ce['alternatives'][0x0][_0x926f('0x44')]:'';})[_0x926f('0x45')]('\x0a');_0x2770c4=_0x214c33[_0x926f('0x41')]['map'](function(_0x3eb7d6){return _0x3eb7d6&&_0x3eb7d6[_0x926f('0x43')][0x0]&&_0x3eb7d6['alternatives'][0x0][_0x926f('0x46')]?_0x3eb7d6[_0x926f('0x43')][0x0][_0x926f('0x46')]:0x0;})['join']('\x0a');}logger[_0x926f('0x18')]('googleASR\x20transcription',_0x3e5f2d);logger[_0x926f('0x18')](_0x926f('0x47'),_0x2770c4);return{'transcript':_0x3e5f2d,'confidence':_0x2770c4};})[_0x926f('0x48')](function(_0x504cb3){logger['error']('[%s]\x20%s:%s',_0x504cb3[_0x926f('0x13')],_0x504cb3[_0x926f('0x49')],_0x504cb3[_0x926f('0x4a')]);});};exports['googleDialogflow']=function(_0x2411cf,_0x3e6e25,_0x6c9830,_0x386af2){var _0x1c217a=apiai(_0x3e6e25,{'language':_0x386af2||'en'});return _0x1c217a[_0x926f('0x4b')](_0x6c9830,{'sessionId':md5(_0x2411cf)})['then'](function(_0x58b692){logger[_0x926f('0x18')](JSON[_0x926f('0x4c')](_0x58b692));return{'source':_0x58b692[_0x926f('0x4d')]['source'],'resolvedQuery':_0x58b692[_0x926f('0x4d')][_0x926f('0x4e')],'action':_0x58b692[_0x926f('0x4d')]['action'],'actionIncomplete':_0x58b692[_0x926f('0x4d')][_0x926f('0x4f')],'speech':_0x58b692['result'][_0x926f('0x50')][_0x926f('0x51')],'score':_0x58b692[_0x926f('0x4d')][_0x926f('0x52')],'statusCode':_0x58b692[_0x926f('0x53')]['code'],'endConversation':_0x58b692[_0x926f('0x4d')][_0x926f('0x54')][_0x926f('0x55')]||![],'isFallbackIntent':_0x58b692['result']['metadata'][_0x926f('0x56')]};});};exports[_0x926f('0x57')]=function(_0x528636,_0x32be74,_0x1009bd,_0x45c647){return tilde[_0x926f('0x3f')](_0x528636,_0x32be74,_0x1009bd,_0x45c647)['then'](function(_0x4a119c){try{fs[_0x926f('0x28')](_0x528636);}catch(_0xa3c62d){logger['error'](_0xa3c62d);}logger['info']('Tilde\x20ASR\x20transcription',_0x4a119c[_0x926f('0x44')]);logger['info'](_0x926f('0x58'),_0x4a119c[_0x926f('0x46')]);return _0x4a119c;});};exports[_0x926f('0x59')]=function(_0x53e953,_0x4478e3,_0x5b308a,_0x555104,_0x80d7ec,_0xe84514){var _0xbd7f4=path[_0x926f('0x22')](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+_0x926f('0x36'));var _0x525f14;return aws[_0x926f('0x5a')](_0x53e953,_0x4478e3,_0x5b308a,_0x555104,_0x80d7ec,_0xe84514,_0xbd7f4)[_0x926f('0x35')](function(){_0x525f14=path[_0x926f('0x22')](__dirname,'tmp',rs['generate'](0x4)+_0x926f('0x25'));return convertFile(_0xbd7f4,_0x525f14);})[_0x926f('0x35')](function(){try{fs[_0x926f('0x28')](_0xbd7f4);fs[_0x926f('0x29')](_0x525f14,_0x926f('0x2a'));}catch(_0x4bef77){logger[_0x926f('0x1b')](_0x4bef77);}return _0x525f14[_0x926f('0x3d')]('.')[0x0];});};exports[_0x926f('0x5b')]=function(_0x1976bb,_0x51666e,_0x478700,_0x217198,_0x3a1f94,_0x337ec3){return aws[_0x926f('0x5c')](_0x1976bb,_0x51666e,_0x478700,_0x217198,_0x3a1f94,_0x337ec3)[_0x926f('0x35')](function(_0x5a431f){logger[_0x926f('0x18')](JSON[_0x926f('0x4c')](_0x5a431f));return _0x5a431f;});};exports[_0x926f('0x5d')]=function(_0x3b9720,_0x566ffc,_0x4c71ea,_0x388958){var _0x4f90c5=util[_0x926f('0x5e')](_0x926f('0x5f'),ISPEECH_API,_0x3b9720,encodeURIComponent(_0x566ffc),_0x4c71ea,_0x388958);var _0x52e9ce=path['resolve'](__dirname,'tmp',rs[_0x926f('0x24')](0x4)+'.mp3');var _0x770944;return downloadFile(_0x4f90c5,_0x52e9ce)[_0x926f('0x35')](function(){_0x770944=path[_0x926f('0x22')](__dirname,_0x926f('0x23'),rs[_0x926f('0x24')](0x4)+'.wav');return convertFile(_0x52e9ce,_0x770944);})[_0x926f('0x35')](function(){try{fs['unlink'](_0x52e9ce);fs[_0x926f('0x29')](_0x770944,_0x926f('0x2a'));}catch(_0x49ddce){logger[_0x926f('0x1b')](_0x49ddce);}return _0x770944[_0x926f('0x3d')]('.')[0x0];});};exports[_0x926f('0x60')]=function(_0x5d6431,_0x2e2b9e,_0x4e790f,_0x7844a0){var _0x2e59d6=util[_0x926f('0x5e')](_0x926f('0x61'),ISPEECH_API,_0x2e2b9e,_0x4e790f,base64Encode(_0x5d6431),_0x7844a0?util[_0x926f('0x5e')](_0x926f('0x62'),encodeURIComponent(_0x7844a0)):'freeform=3');return uploadFile(_0x2e59d6)['then'](function(_0x40df5a){return querystring[_0x926f('0x3')](_0x40df5a);});};exports[_0x926f('0x63')]=function(_0x167285,_0x958e72){return sestek[_0x926f('0x64')](_0x167285,_0x958e72)['then'](function(_0x34c915){logger[_0x926f('0x18')](JSON['stringify'](_0x34c915));var _0x39d0fe={'speech':_0x34c915[_0x926f('0x65')],'action':_0x34c915[_0x926f('0x66')]?_0x34c915[_0x926f('0x66')][_0x926f('0x67')]:undefined,'actiondata':_0x34c915[_0x926f('0x66')]?_0x34c915[_0x926f('0x66')][_0x926f('0x68')]:undefined};if(_0x34c915[_0x926f('0x66')]&&_0x34c915[_0x926f('0x66')][_0x926f('0x69')]){return base64Decode(_0x34c915[_0x926f('0x66')][_0x926f('0x69')][_0x926f('0x6a')],path['resolve'](__dirname,'tmp',rs[_0x926f('0x24')](0x4)+_0x926f('0x25')))['then'](function(_0x33bcef){_0x39d0fe['audiofile']=_0x33bcef;return _0x39d0fe;});}return _0x39d0fe;});};exports[_0x926f('0x6b')]=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