Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / config / schedule / transcribe.js
index fd7f42c..f331652 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb077=['transcribeName','data2','transcribeRegion','then','TranscriptionJob','TranscriptionJobStatus','fileText','COMPLETED','[RECORDING:%d]\x20Get\x20transcript','Transcript','TranscriptFileUri','[RECORDING:%d]\x20Transcript\x20downloaded','results','length','transcripts','update','[RECORDING:%d]\x20Voice\x20Recording\x20entry\x20updated','tempSentiment','Sequelize','ValidationError','Sentiment\x20Analysis\x20not\x20requested','sentiment','sentimentAccountId','sentimentRegion','language','bucket','Transcript\x20not\x20available','CloudProvider','Cloud\x20Provider\x20not\x20available','Cloud\x20Provider\x20not\x20configured','[RECORDING:%d]\x20Requesting\x20sentiment\x20analysis','[RECORDING:%d]\x20Sentiment\x20Analysis\x20available','Sentiment','SentimentScore','Positive','Negative','Mixed','Neutral','FAILED','FailureReason','[RECORDING:%d]\x20Transcript\x20Job\x20status\x20not\x20managed','Sentiment\x20Analysis\x20not\x20configured','findOne','catch','name','SequelizeValidationError','error','inspect','No\x20transcribe\x20job\x20to\x20check','Setting','Settings\x20not\x20available','transcribeAccountId','forEach','push','all','start','lodash','util','../../mysqldb','../../config/logger','transcribe','Comprehend','substring','info','format','[RECORDING:%d]\x20Get\x20status\x20for\x20transcript\x20job\x20(%s)'];(function(_0x9fb10d,_0xa7970e){var _0x54f389=function(_0x344a38){while(--_0x344a38){_0x9fb10d['push'](_0x9fb10d['shift']());}};_0x54f389(++_0xa7970e);}(_0xb077,0x7a));var _0x7b07=function(_0x331cf8,_0x29c108){_0x331cf8=_0x331cf8-0x0;var _0x5b0bc6=_0xb077[_0x331cf8];return _0x5b0bc6;};var _=require(_0x7b07('0x0'));var AWS=require('aws-sdk');var rp=require('request-promise');var util=require(_0x7b07('0x1'));var BPromise=require('bluebird');var db=require(_0x7b07('0x2'))['db'];var logger=require(_0x7b07('0x3'))(_0x7b07('0x4'));function getTranscriptionJob(_0x2b0c6c,_0x423957,_0x5df1bf,_0x5722bb){return new Promise(function(_0xdc333,_0x325d95){var _0x110ee5=new AWS['TranscribeService']({'accessKeyId':_0x423957,'secretAccessKey':_0x2b0c6c,'region':_0x5df1bf});_0x110ee5['getTranscriptionJob']({'TranscriptionJobName':_0x5722bb},function(_0x3a82e8,_0x4b6f20){if(_0x3a82e8){return _0x325d95(_0x3a82e8);}else{return _0xdc333(_0x4b6f20);}});});}function sentiment(_0x3dd0ad,_0x292db1,_0x2d3741,_0x214052,_0x1e8092){return new Promise(function(_0x23522e,_0x2f7009){var _0x33a461=new AWS[(_0x7b07('0x5'))]({'accessKeyId':_0x292db1,'secretAccessKey':_0x3dd0ad,'region':_0x2d3741});_0x33a461['detectSentiment']({'Text':_0x214052,'LanguageCode':_0x1e8092[_0x7b07('0x6')](0x0,0x2)},function(_0x282fe2,_0x1ffc7c){if(_0x282fe2){return _0x2f7009(_0x282fe2);}else{return _0x23522e(_0x1ffc7c);}});});}function checkTranscribeJob(_0x5684db,_0xe825c4,_0x3d73c6){var _0x9f3404;return new BPromise(function(_0x7930f1,_0x530d1d){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x9'),_0x5684db['id'],_0x5684db[_0x7b07('0xa')]));return getTranscriptionJob(_0x3d73c6['data1'],_0x3d73c6[_0x7b07('0xb')],_0xe825c4[_0x7b07('0xc')],_0x5684db[_0x7b07('0xa')])[_0x7b07('0xd')](function(_0x4b7d85){logger['info'](util['format']('[RECORDING:%d]\x20Status\x20of\x20transcript\x20job\x20(%s):\x20%s',_0x5684db['id'],_0x5684db[_0x7b07('0xa')],_0x4b7d85[_0x7b07('0xe')][_0x7b07('0xf')]));if(!_0x5684db[_0x7b07('0x10')]){switch(_0x4b7d85[_0x7b07('0xe')][_0x7b07('0xf')]){case _0x7b07('0x11'):var _0x5141d7={'transcribeStatus':_0x4b7d85[_0x7b07('0xe')][_0x7b07('0xf')],'fileUri':_0x4b7d85['TranscriptionJob']['Transcript']['TranscriptFileUri']};logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x12'),_0x5684db['id']));return rp({'uri':_0x4b7d85[_0x7b07('0xe')][_0x7b07('0x13')][_0x7b07('0x14')],'json':!![]})[_0x7b07('0xd')](function(_0x481812){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x15'),_0x5684db['id']));if(_0x481812&&_0x481812['results']&&_0x481812[_0x7b07('0x16')]['transcripts']&&_0x481812[_0x7b07('0x16')]['transcripts'][_0x7b07('0x17')]){_0x5141d7[_0x7b07('0x10')]='';for(var _0x23f830=0x0;_0x23f830<_0x481812[_0x7b07('0x16')]['transcripts'][_0x7b07('0x17')];_0x23f830++){_0x5141d7['fileText']+=_0x481812[_0x7b07('0x16')][_0x7b07('0x18')][_0x23f830]['transcript']+'';}}return _0x5684db[_0x7b07('0x19')](_0x5141d7);})[_0x7b07('0xd')](function(){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x1a'),_0x5684db['id']));if(!_0x5684db[_0x7b07('0x1b')]){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))](_0x7b07('0x1e'));}if(!_0xe825c4[_0x7b07('0x1f')]||!_0xe825c4[_0x7b07('0x20')]||!_0xe825c4[_0x7b07('0x21')]||!_0xe825c4[_0x7b07('0x22')]||!_0xe825c4[_0x7b07('0x23')]){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))]('Sentiment\x20Analysis\x20not\x20configured');}if(!_0x5141d7['fileText']){throw new Error(_0x7b07('0x24'));}if(_0xe825c4[_0x7b07('0x20')]===_0x3d73c6['id']){return _0x3d73c6;}else{return db[_0x7b07('0x25')]['findOne']({'where':{'id':_settings[_0x7b07('0x20')]}});}})[_0x7b07('0xd')](function(_0x15713b){if(!_0x15713b){throw new db[(_0x7b07('0x1c'))]['ValidationError'](_0x7b07('0x26'));}if(!_0x15713b['data1']||!_0x15713b[_0x7b07('0xb')]){throw new db['Sequelize'][(_0x7b07('0x1d'))](_0x7b07('0x27'));}_0x9f3404=_0x15713b;logger['info'](util['format'](_0x7b07('0x28'),_0x5684db['id']));return sentiment(_0x9f3404['data1'],_0x9f3404[_0x7b07('0xb')],_0xe825c4[_0x7b07('0x21')],_0x5141d7['fileText'],_0xe825c4[_0x7b07('0x22')]);})['then'](function(_0x661e89){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x29'),_0x5684db['id']));return _0x5684db[_0x7b07('0x19')]({'sentiment':_0x661e89[_0x7b07('0x2a')],'sPositive':_0x661e89[_0x7b07('0x2b')][_0x7b07('0x2c')],'sNegative':_0x661e89[_0x7b07('0x2b')][_0x7b07('0x2d')],'sMixed':_0x661e89[_0x7b07('0x2b')][_0x7b07('0x2e')],'sNeutral':_0x661e89[_0x7b07('0x2b')][_0x7b07('0x2f')]});})[_0x7b07('0xd')](function(){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x1a'),_0x5684db['id']));_0x7930f1();});case _0x7b07('0x30'):return _0x5684db[_0x7b07('0x19')]({'transcribeStatus':'FAILED','failureReason':_0x4b7d85[_0x7b07('0xe')][_0x7b07('0x31')]})[_0x7b07('0xd')](function(){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x1a'),_0x5684db['id']));_0x7930f1();});default:logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x32'),_0x5684db['id']));break;}}else{return BPromise['resolve']()[_0x7b07('0xd')](function(){if(!_0x5684db[_0x7b07('0x1b')]){throw new db['Sequelize'][(_0x7b07('0x1d'))](_0x7b07('0x1e'));}if(!_0xe825c4['sentiment']||!_0xe825c4[_0x7b07('0x20')]||!_0xe825c4[_0x7b07('0x21')]||!_0xe825c4[_0x7b07('0x22')]||!_0xe825c4[_0x7b07('0x23')]){throw new db[(_0x7b07('0x1c'))]['ValidationError'](_0x7b07('0x33'));}if(!_0x5684db[_0x7b07('0x10')]){throw new Error(_0x7b07('0x24'));}if(_0xe825c4[_0x7b07('0x20')]===_0x3d73c6['id']){return _0x3d73c6;}else{return db[_0x7b07('0x25')][_0x7b07('0x34')]({'where':{'id':_settings[_0x7b07('0x20')]}});}})[_0x7b07('0xd')](function(_0x523355){if(!_0x523355){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))](_0x7b07('0x26'));}if(!_0x523355['data1']||!_0x523355[_0x7b07('0xb')]){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))]('Cloud\x20Provider\x20not\x20configured');}_0x9f3404=_0x523355;logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x28'),_0x5684db['id']));return sentiment(_0x9f3404['data1'],_0x9f3404[_0x7b07('0xb')],_0xe825c4['sentimentRegion'],_0x5684db[_0x7b07('0x10')],_0xe825c4[_0x7b07('0x22')]);})[_0x7b07('0xd')](function(_0x55a96d){logger[_0x7b07('0x7')](util[_0x7b07('0x8')]('[RECORDING:%d]\x20Sentiment\x20Analysis\x20available',_0x5684db['id']));return _0x5684db['update']({'sentiment':_0x55a96d[_0x7b07('0x2a')],'sPositive':_0x55a96d['SentimentScore'][_0x7b07('0x2c')],'sNegative':_0x55a96d[_0x7b07('0x2b')]['Negative'],'sMixed':_0x55a96d['SentimentScore'][_0x7b07('0x2e')],'sNeutral':_0x55a96d[_0x7b07('0x2b')]['Neutral'],'transcribeStatus':_0x7b07('0x11')});})[_0x7b07('0xd')](function(){logger[_0x7b07('0x7')](util[_0x7b07('0x8')](_0x7b07('0x1a'),_0x5684db['id']));_0x7930f1();});}})[_0x7b07('0x35')](function(_0xddd3b7){if(_0xddd3b7){if(!_0xddd3b7[_0x7b07('0x36')]||_0xddd3b7[_0x7b07('0x36')]!==_0x7b07('0x37')){logger[_0x7b07('0x38')](util[_0x7b07('0x8')]('[RECORDING:%d]\x20Error\x20running\x20Transcribe\x20&\x20Sentiment\x20Analysis',_0x5684db['id']),util[_0x7b07('0x39')](_0xddd3b7,{'showHidden':![],'depth':null}));}}_0x7930f1();});});}function checkTranscribe(){var _0x30ec1b;var _0x3e5593;var _0x4fc266;return db['VoiceRecording']['findAll']({'where':{'transcribeStatus':'IN_PROGRESS'}})[_0x7b07('0xd')](function(_0x2ed908){if(!_0x2ed908||!_0x2ed908[_0x7b07('0x17')]){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))](_0x7b07('0x3a'));}_0x30ec1b=_0x2ed908;return db[_0x7b07('0x3b')][_0x7b07('0x34')]({'where':{'id':0x1}});})['then'](function(_0x2c2605){if(!_0x2c2605){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))](_0x7b07('0x3c'));}_0x3e5593=_0x2c2605;if(!_0x3e5593[_0x7b07('0x4')]||!_0x3e5593['transcribeAccountId']||!_0x3e5593[_0x7b07('0xc')]||!_0x3e5593[_0x7b07('0x22')]||!_0x3e5593[_0x7b07('0x23')]){throw new db[(_0x7b07('0x1c'))][(_0x7b07('0x1d'))]('Transcribe\x20not\x20configured');}return db[_0x7b07('0x25')][_0x7b07('0x34')]({'where':{'id':_0x3e5593[_0x7b07('0x3d')]}});})['then'](function(_0x53777d){if(!_0x53777d){throw new db['Sequelize'][(_0x7b07('0x1d'))](_0x7b07('0x26'));}if(!_0x53777d['data1']||!_0x53777d[_0x7b07('0xb')]){throw new db[(_0x7b07('0x1c'))]['ValidationError'](_0x7b07('0x27'));}_0x4fc266=_0x53777d;var _0x92e583=[];_0x30ec1b[_0x7b07('0x3e')](function(_0x516676){_0x92e583[_0x7b07('0x3f')](checkTranscribeJob(_0x516676,_0x3e5593,_0x4fc266));});return BPromise[_0x7b07('0x40')](_0x92e583);})[_0x7b07('0x35')](function(_0x188590){if(_0x188590){if(!_0x188590[_0x7b07('0x36')]||_0x188590['name']!==_0x7b07('0x37')){logger[_0x7b07('0x38')](util[_0x7b07('0x39')](_0x188590,{'showHidden':![],'depth':null}));}}});}exports[_0x7b07('0x41')]=function(){setInterval(function(){return checkTranscribe();},0x3c*0x3e8);return checkTranscribe();};
\ No newline at end of file
+var _0xa20a=['transcript','[RECORDING:%d]\x20Voice\x20Recording\x20entry\x20updated','tempSentiment','Sequelize','Sentiment\x20Analysis\x20not\x20requested','sentimentRegion','language','bucket','Transcript\x20not\x20available','CloudProvider','findOne','sentimentAccountId','ValidationError','Cloud\x20Provider\x20not\x20available','Cloud\x20Provider\x20not\x20configured','[RECORDING:%d]\x20Sentiment\x20Analysis\x20available','update','Sentiment','SentimentScore','Positive','Negative','Mixed','FAILED','FailureReason','[RECORDING:%d]\x20Transcript\x20Job\x20status\x20not\x20managed','resolve','sentiment','Sentiment\x20Analysis\x20not\x20configured','Neutral','name','SequelizeValidationError','error','[RECORDING:%d]\x20Error\x20running\x20Transcribe\x20&\x20Sentiment\x20Analysis','inspect','findAll','No\x20transcribe\x20job\x20to\x20check','Setting','Settings\x20not\x20available','transcribeAccountId','Transcribe\x20not\x20configured','forEach','push','all','start','request-promise','util','bluebird','../../mysqldb','transcribe','TranscribeService','getTranscriptionJob','Comprehend','substring','info','format','[RECORDING:%d]\x20Get\x20status\x20for\x20transcript\x20job\x20(%s)','transcribeName','data1','data2','transcribeRegion','then','[RECORDING:%d]\x20Status\x20of\x20transcript\x20job\x20(%s):\x20%s','TranscriptionJob','fileText','TranscriptionJobStatus','COMPLETED','Transcript','TranscriptFileUri','[RECORDING:%d]\x20Transcript\x20downloaded','results','transcripts','length'];(function(_0x1ead8f,_0x325f7d){var _0x87e090=function(_0x2a42d1){while(--_0x2a42d1){_0x1ead8f['push'](_0x1ead8f['shift']());}};_0x87e090(++_0x325f7d);}(_0xa20a,0x74));var _0xaa20=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0xa20a[_0x40a045];return _0x1a687c;};var _=require('lodash');var AWS=require('aws-sdk');var rp=require(_0xaa20('0x0'));var util=require(_0xaa20('0x1'));var BPromise=require(_0xaa20('0x2'));var db=require(_0xaa20('0x3'))['db'];var logger=require('../../config/logger')(_0xaa20('0x4'));function getTranscriptionJob(_0x20a8ad,_0x1497a0,_0x40cb4c,_0x46ae89){return new Promise(function(_0x5ac74e,_0x54ecbc){var _0x413b88=new AWS[(_0xaa20('0x5'))]({'accessKeyId':_0x1497a0,'secretAccessKey':_0x20a8ad,'region':_0x40cb4c});_0x413b88[_0xaa20('0x6')]({'TranscriptionJobName':_0x46ae89},function(_0x181df0,_0x271ed1){if(_0x181df0){return _0x54ecbc(_0x181df0);}else{return _0x5ac74e(_0x271ed1);}});});}function sentiment(_0x1983e8,_0x1e0186,_0x12d403,_0x17692f,_0x1f1d3a){return new Promise(function(_0x3b71a4,_0x590395){var _0xcc3d59=new AWS[(_0xaa20('0x7'))]({'accessKeyId':_0x1e0186,'secretAccessKey':_0x1983e8,'region':_0x12d403});_0xcc3d59['detectSentiment']({'Text':_0x17692f,'LanguageCode':_0x1f1d3a[_0xaa20('0x8')](0x0,0x2)},function(_0x249f4a,_0x2d527a){if(_0x249f4a){return _0x590395(_0x249f4a);}else{return _0x3b71a4(_0x2d527a);}});});}function checkTranscribeJob(_0x1e18cc,_0x36f915,_0x2fdd4f){var _0x48848f;return new BPromise(function(_0x2ef6e3,_0x163677){logger[_0xaa20('0x9')](util[_0xaa20('0xa')](_0xaa20('0xb'),_0x1e18cc['id'],_0x1e18cc[_0xaa20('0xc')]));return getTranscriptionJob(_0x2fdd4f[_0xaa20('0xd')],_0x2fdd4f[_0xaa20('0xe')],_0x36f915[_0xaa20('0xf')],_0x1e18cc[_0xaa20('0xc')])[_0xaa20('0x10')](function(_0x30f531){logger[_0xaa20('0x9')](util[_0xaa20('0xa')](_0xaa20('0x11'),_0x1e18cc['id'],_0x1e18cc[_0xaa20('0xc')],_0x30f531[_0xaa20('0x12')]['TranscriptionJobStatus']));if(!_0x1e18cc[_0xaa20('0x13')]){switch(_0x30f531['TranscriptionJob'][_0xaa20('0x14')]){case _0xaa20('0x15'):var _0x4c0bdb={'transcribeStatus':_0x30f531[_0xaa20('0x12')][_0xaa20('0x14')],'fileUri':_0x30f531[_0xaa20('0x12')][_0xaa20('0x16')][_0xaa20('0x17')]};logger['info'](util['format']('[RECORDING:%d]\x20Get\x20transcript',_0x1e18cc['id']));return rp({'uri':_0x30f531['TranscriptionJob']['Transcript'][_0xaa20('0x17')],'json':!![]})[_0xaa20('0x10')](function(_0x10c96e){logger[_0xaa20('0x9')](util[_0xaa20('0xa')](_0xaa20('0x18'),_0x1e18cc['id']));if(_0x10c96e&&_0x10c96e[_0xaa20('0x19')]&&_0x10c96e[_0xaa20('0x19')][_0xaa20('0x1a')]&&_0x10c96e['results']['transcripts'][_0xaa20('0x1b')]){_0x4c0bdb[_0xaa20('0x13')]='';for(var _0x55ac29=0x0;_0x55ac29<_0x10c96e[_0xaa20('0x19')][_0xaa20('0x1a')]['length'];_0x55ac29++){_0x4c0bdb[_0xaa20('0x13')]+=_0x10c96e[_0xaa20('0x19')]['transcripts'][_0x55ac29][_0xaa20('0x1c')]+'';}}return _0x1e18cc['update'](_0x4c0bdb);})[_0xaa20('0x10')](function(){logger[_0xaa20('0x9')](util[_0xaa20('0xa')](_0xaa20('0x1d'),_0x1e18cc['id']));if(!_0x1e18cc[_0xaa20('0x1e')]){throw new db[(_0xaa20('0x1f'))]['ValidationError'](_0xaa20('0x20'));}if(!_0x36f915['sentiment']||!_0x36f915['sentimentAccountId']||!_0x36f915[_0xaa20('0x21')]||!_0x36f915[_0xaa20('0x22')]||!_0x36f915[_0xaa20('0x23')]){throw new db[(_0xaa20('0x1f'))]['ValidationError']('Sentiment\x20Analysis\x20not\x20configured');}if(!_0x4c0bdb[_0xaa20('0x13')]){throw new Error(_0xaa20('0x24'));}if(_0x36f915['sentimentAccountId']===_0x2fdd4f['id']){return _0x2fdd4f;}else{return db[_0xaa20('0x25')][_0xaa20('0x26')]({'where':{'id':_settings[_0xaa20('0x27')]}});}})[_0xaa20('0x10')](function(_0x27b988){if(!_0x27b988){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))](_0xaa20('0x29'));}if(!_0x27b988[_0xaa20('0xd')]||!_0x27b988[_0xaa20('0xe')]){throw new db['Sequelize'][(_0xaa20('0x28'))](_0xaa20('0x2a'));}_0x48848f=_0x27b988;logger[_0xaa20('0x9')](util[_0xaa20('0xa')]('[RECORDING:%d]\x20Requesting\x20sentiment\x20analysis',_0x1e18cc['id']));return sentiment(_0x48848f['data1'],_0x48848f[_0xaa20('0xe')],_0x36f915[_0xaa20('0x21')],_0x4c0bdb[_0xaa20('0x13')],_0x36f915['language']);})[_0xaa20('0x10')](function(_0x2cf8a0){logger[_0xaa20('0x9')](util['format'](_0xaa20('0x2b'),_0x1e18cc['id']));return _0x1e18cc[_0xaa20('0x2c')]({'sentiment':_0x2cf8a0[_0xaa20('0x2d')],'sPositive':_0x2cf8a0[_0xaa20('0x2e')][_0xaa20('0x2f')],'sNegative':_0x2cf8a0[_0xaa20('0x2e')][_0xaa20('0x30')],'sMixed':_0x2cf8a0['SentimentScore'][_0xaa20('0x31')],'sNeutral':_0x2cf8a0['SentimentScore']['Neutral']});})[_0xaa20('0x10')](function(){logger[_0xaa20('0x9')](util['format'](_0xaa20('0x1d'),_0x1e18cc['id']));_0x2ef6e3();});case _0xaa20('0x32'):return _0x1e18cc[_0xaa20('0x2c')]({'transcribeStatus':_0xaa20('0x32'),'failureReason':_0x30f531[_0xaa20('0x12')][_0xaa20('0x33')]})[_0xaa20('0x10')](function(){logger[_0xaa20('0x9')](util[_0xaa20('0xa')](_0xaa20('0x1d'),_0x1e18cc['id']));_0x2ef6e3();});default:logger[_0xaa20('0x9')](util[_0xaa20('0xa')](_0xaa20('0x34'),_0x1e18cc['id']));break;}}else{return BPromise[_0xaa20('0x35')]()['then'](function(){if(!_0x1e18cc[_0xaa20('0x1e')]){throw new db['Sequelize']['ValidationError']('Sentiment\x20Analysis\x20not\x20requested');}if(!_0x36f915[_0xaa20('0x36')]||!_0x36f915['sentimentAccountId']||!_0x36f915[_0xaa20('0x21')]||!_0x36f915['language']||!_0x36f915[_0xaa20('0x23')]){throw new db['Sequelize'][(_0xaa20('0x28'))](_0xaa20('0x37'));}if(!_0x1e18cc[_0xaa20('0x13')]){throw new Error('Transcript\x20not\x20available');}if(_0x36f915[_0xaa20('0x27')]===_0x2fdd4f['id']){return _0x2fdd4f;}else{return db[_0xaa20('0x25')][_0xaa20('0x26')]({'where':{'id':_settings[_0xaa20('0x27')]}});}})[_0xaa20('0x10')](function(_0x1481c3){if(!_0x1481c3){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))](_0xaa20('0x29'));}if(!_0x1481c3['data1']||!_0x1481c3[_0xaa20('0xe')]){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))](_0xaa20('0x2a'));}_0x48848f=_0x1481c3;logger['info'](util['format']('[RECORDING:%d]\x20Requesting\x20sentiment\x20analysis',_0x1e18cc['id']));return sentiment(_0x48848f['data1'],_0x48848f['data2'],_0x36f915[_0xaa20('0x21')],_0x1e18cc[_0xaa20('0x13')],_0x36f915['language']);})[_0xaa20('0x10')](function(_0x34da3c){logger[_0xaa20('0x9')](util['format']('[RECORDING:%d]\x20Sentiment\x20Analysis\x20available',_0x1e18cc['id']));return _0x1e18cc['update']({'sentiment':_0x34da3c[_0xaa20('0x2d')],'sPositive':_0x34da3c['SentimentScore'][_0xaa20('0x2f')],'sNegative':_0x34da3c['SentimentScore'][_0xaa20('0x30')],'sMixed':_0x34da3c[_0xaa20('0x2e')][_0xaa20('0x31')],'sNeutral':_0x34da3c[_0xaa20('0x2e')][_0xaa20('0x38')],'transcribeStatus':_0xaa20('0x15')});})[_0xaa20('0x10')](function(){logger['info'](util[_0xaa20('0xa')]('[RECORDING:%d]\x20Voice\x20Recording\x20entry\x20updated',_0x1e18cc['id']));_0x2ef6e3();});}})['catch'](function(_0x19df3b){if(_0x19df3b){if(!_0x19df3b[_0xaa20('0x39')]||_0x19df3b[_0xaa20('0x39')]!==_0xaa20('0x3a')){logger[_0xaa20('0x3b')](util[_0xaa20('0xa')](_0xaa20('0x3c'),_0x1e18cc['id']),util[_0xaa20('0x3d')](_0x19df3b,{'showHidden':![],'depth':null}));}}_0x2ef6e3();});});}function checkTranscribe(){var _0x21cdbd;var _0x597d12;var _0x14de4a;return db['VoiceRecording'][_0xaa20('0x3e')]({'where':{'transcribeStatus':'IN_PROGRESS'}})[_0xaa20('0x10')](function(_0x209a48){if(!_0x209a48||!_0x209a48['length']){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))](_0xaa20('0x3f'));}_0x21cdbd=_0x209a48;return db[_0xaa20('0x40')][_0xaa20('0x26')]({'where':{'id':0x1}});})['then'](function(_0x3a9b1a){if(!_0x3a9b1a){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))](_0xaa20('0x41'));}_0x597d12=_0x3a9b1a;if(!_0x597d12[_0xaa20('0x4')]||!_0x597d12[_0xaa20('0x42')]||!_0x597d12[_0xaa20('0xf')]||!_0x597d12[_0xaa20('0x22')]||!_0x597d12[_0xaa20('0x23')]){throw new db['Sequelize'][(_0xaa20('0x28'))](_0xaa20('0x43'));}return db['CloudProvider'][_0xaa20('0x26')]({'where':{'id':_0x597d12['transcribeAccountId']}});})[_0xaa20('0x10')](function(_0x23174e){if(!_0x23174e){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))](_0xaa20('0x29'));}if(!_0x23174e[_0xaa20('0xd')]||!_0x23174e[_0xaa20('0xe')]){throw new db[(_0xaa20('0x1f'))][(_0xaa20('0x28'))]('Cloud\x20Provider\x20not\x20configured');}_0x14de4a=_0x23174e;var _0xdb599f=[];_0x21cdbd[_0xaa20('0x44')](function(_0x5e6bfa){_0xdb599f[_0xaa20('0x45')](checkTranscribeJob(_0x5e6bfa,_0x597d12,_0x14de4a));});return BPromise[_0xaa20('0x46')](_0xdb599f);})['catch'](function(_0x15f764){if(_0x15f764){if(!_0x15f764['name']||_0x15f764[_0xaa20('0x39')]!==_0xaa20('0x3a')){logger[_0xaa20('0x3b')](util[_0xaa20('0x3d')](_0x15f764,{'showHidden':![],'depth':null}));}}});}exports[_0xaa20('0x47')]=function(){setInterval(function(){return checkTranscribe();},0x3c*0x3e8);return checkTranscribe();};
\ No newline at end of file