ce37b0fab09ab573cd958906f99b712e899c94eb
[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 _0xc311=['Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','mp3','path','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile'];(function(_0x45b034,_0x3a57dd){var _0x509cb0=function(_0x3a89d5){while(--_0x3a89d5){_0x45b034['push'](_0x45b034['shift']());}};_0x509cb0(++_0x3a57dd);}(_0xc311,0x131));var _0x1c31=function(_0x3315ff,_0x321860){_0x3315ff=_0x3315ff-0x0;var _0xec5af2=_0xc311[_0x3315ff];return _0xec5af2;};'use strict';var fs=require('fs');var path=require(_0x1c31('0x0'));var BPromise=require(_0x1c31('0x1'));var rs=require(_0x1c31('0x2'));var AWS=require(_0x1c31('0x3'));function pollyResult(_0x41f715,_0x57fea3,_0x27c02a){return new BPromise(function(_0x17f034,_0x494d09){_0x41f715[_0x1c31('0x4')](_0x57fea3,function(_0x462de2,_0x2d0bdd){if(_0x462de2){_0x494d09(_0x462de2);}else if(_0x2d0bdd){if(_0x2d0bdd[_0x1c31('0x5')]instanceof Buffer){fs[_0x1c31('0x6')](_0x27c02a,_0x2d0bdd['AudioStream'],function(_0x12c8f3){if(_0x12c8f3){_0x494d09(_0x12c8f3);}else{_0x17f034();}});}else{_0x494d09(new Error(_0x1c31('0x7')));}}else{_0x494d09(new Error(_0x1c31('0x8')));}});});}module[_0x1c31('0x9')]=function(_0x3aa5e3,_0x26559b,_0x5df3fb,_0x3fc070,_0x2df1ca,_0x38b7b7,_0x586b74){var _0x5db170=new AWS[(_0x1c31('0xa'))]({'accessKeyId':_0x3aa5e3,'secretAccessKey':_0x26559b,'region':_0x5df3fb});var _0x2d9c19={'Text':_0x2df1ca,'TextType':_0x38b7b7||_0x1c31('0xb'),'OutputFormat':_0x1c31('0xc'),'VoiceId':_0x3fc070};return pollyResult(_0x5db170,_0x2d9c19,_0x586b74);};