Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / services / agi / scripts / aws / polly / lib / api.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xed8d=['AudioStream','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','mp3','path','bluebird','randomstring','synthesizeSpeech','writeFile'];(function(_0x32cd47,_0x374c1c){var _0x13c48b=function(_0x1502f3){while(--_0x1502f3){_0x32cd47['push'](_0x32cd47['shift']());}};_0x13c48b(++_0x374c1c);}(_0xed8d,0x1d8));var _0xded8=function(_0x4c4bc8,_0x1151b8){_0x4c4bc8=_0x4c4bc8-0x0;var _0x5e07f8=_0xed8d[_0x4c4bc8];return _0x5e07f8;};'use strict';var fs=require('fs');var path=require(_0xded8('0x0'));var BPromise=require(_0xded8('0x1'));var rs=require(_0xded8('0x2'));var AWS=require('aws-sdk');function pollyResult(_0x1109e9,_0x46f258,_0x352cdf){return new BPromise(function(_0x2a445b,_0x19a439){_0x1109e9[_0xded8('0x3')](_0x46f258,function(_0x6c2dba,_0xe8d7cb){if(_0x6c2dba){_0x19a439(_0x6c2dba);}else if(_0xe8d7cb){if(_0xe8d7cb['AudioStream']instanceof Buffer){fs[_0xded8('0x4')](_0x352cdf,_0xe8d7cb[_0xded8('0x5')],function(_0x3098ba){if(_0x3098ba){_0x19a439(_0x3098ba);}else{_0x2a445b();}});}else{_0x19a439(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x19a439(new Error(_0xded8('0x6')));}});});}module[_0xded8('0x7')]=function(_0x23fcaf,_0x4e9962,_0x1080a3,_0x3b318d,_0x3ecbaa,_0xcf61bc,_0x3a6bce){var _0x47f5fd=new AWS['Polly']({'accessKeyId':_0x23fcaf,'secretAccessKey':_0x4e9962,'region':_0x1080a3});var _0x2be114={'Text':_0x3ecbaa,'TextType':_0xcf61bc||'text','OutputFormat':_0xded8('0x8'),'VoiceId':_0x3b318d};return pollyResult(_0x47f5fd,_0x2be114,_0x3a6bce);};