aa06fe548e10617d9e4e6327756243ba63b03257
[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 _0xe55d=['text','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile','No\x20data\x20response\x20from\x20aws\x20Polly!','exports'];(function(_0x3e6b2f,_0x1ffa07){var _0x323215=function(_0x5c4d82){while(--_0x5c4d82){_0x3e6b2f['push'](_0x3e6b2f['shift']());}};_0x323215(++_0x1ffa07);}(_0xe55d,0x12a));var _0xde55=function(_0x371fd7,_0x1471b3){_0x371fd7=_0x371fd7-0x0;var _0x3fb479=_0xe55d[_0x371fd7];return _0x3fb479;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0xde55('0x0'));var rs=require(_0xde55('0x1'));var AWS=require(_0xde55('0x2'));function pollyResult(_0x32752b,_0x269adc,_0x2fac90){return new BPromise(function(_0x32fec0,_0x48c133){_0x32752b[_0xde55('0x3')](_0x269adc,function(_0x5889ef,_0x5e8791){if(_0x5889ef){_0x48c133(_0x5889ef);}else if(_0x5e8791){if(_0x5e8791[_0xde55('0x4')]instanceof Buffer){fs[_0xde55('0x5')](_0x2fac90,_0x5e8791[_0xde55('0x4')],function(_0x32be83){if(_0x32be83){_0x48c133(_0x32be83);}else{_0x32fec0();}});}else{_0x48c133(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x48c133(new Error(_0xde55('0x6')));}});});}module[_0xde55('0x7')]=function(_0x508fe8,_0xdc6898,_0x5db496,_0x77b844,_0xee9ed0,_0x2c70e6,_0x49c030){var _0x25a7ec=new AWS['Polly']({'accessKeyId':_0x508fe8,'secretAccessKey':_0xdc6898,'region':_0x5db496});var _0x42c400={'Text':_0xee9ed0,'TextType':_0x2c70e6||_0xde55('0x8'),'OutputFormat':'mp3','VoiceId':_0x77b844};return pollyResult(_0x25a7ec,_0x42c400,_0x49c030);};