Built motion from commit (unavailable).|2.5.3
[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 _0x63b5=['No\x20data\x20response\x20from\x20aws\x20Polly!','Polly','text','mp3','path','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile'];(function(_0x40220a,_0x22feb1){var _0x3903cc=function(_0x33a296){while(--_0x33a296){_0x40220a['push'](_0x40220a['shift']());}};_0x3903cc(++_0x22feb1);}(_0x63b5,0xd6));var _0x563b=function(_0x1221fc,_0x1ce6b1){_0x1221fc=_0x1221fc-0x0;var _0x494b35=_0x63b5[_0x1221fc];return _0x494b35;};'use strict';var fs=require('fs');var path=require(_0x563b('0x0'));var BPromise=require('bluebird');var rs=require(_0x563b('0x1'));var AWS=require(_0x563b('0x2'));function pollyResult(_0x258ec4,_0x2a5fea,_0x5b913b){return new BPromise(function(_0x3c8ad0,_0x3d40fe){_0x258ec4[_0x563b('0x3')](_0x2a5fea,function(_0x10b4b1,_0x699380){if(_0x10b4b1){_0x3d40fe(_0x10b4b1);}else if(_0x699380){if(_0x699380[_0x563b('0x4')]instanceof Buffer){fs[_0x563b('0x5')](_0x5b913b,_0x699380['AudioStream'],function(_0x133133){if(_0x133133){_0x3d40fe(_0x133133);}else{_0x3c8ad0();}});}else{_0x3d40fe(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x3d40fe(new Error(_0x563b('0x6')));}});});}module['exports']=function(_0xd3b104,_0x486ce3,_0x4ebfdc,_0x375788,_0x3d10fd,_0x387b81,_0x38d371){var _0x49e839=new AWS[(_0x563b('0x7'))]({'accessKeyId':_0xd3b104,'secretAccessKey':_0x486ce3,'region':_0x4ebfdc});var _0x297133={'Text':_0x3d10fd,'TextType':_0x387b81||_0x563b('0x8'),'OutputFormat':_0x563b('0x9'),'VoiceId':_0x375788};return pollyResult(_0x49e839,_0x297133,_0x38d371);};