9b6cd35db36d3d1b00d85905d851f0378186d709
[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 _0xe127=['randomstring','aws-sdk','synthesizeSpeech','AudioStream','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','mp3','path','bluebird'];(function(_0x1babb2,_0x3b9919){var _0x487730=function(_0x49c606){while(--_0x49c606){_0x1babb2['push'](_0x1babb2['shift']());}};_0x487730(++_0x3b9919);}(_0xe127,0xe2));var _0x7e12=function(_0x3f594b,_0x30a2f6){_0x3f594b=_0x3f594b-0x0;var _0x3c66dc=_0xe127[_0x3f594b];return _0x3c66dc;};'use strict';var fs=require('fs');var path=require(_0x7e12('0x0'));var BPromise=require(_0x7e12('0x1'));var rs=require(_0x7e12('0x2'));var AWS=require(_0x7e12('0x3'));function pollyResult(_0x2925d5,_0x1fc86c,_0x44624f){return new BPromise(function(_0x290063,_0x54ab74){_0x2925d5[_0x7e12('0x4')](_0x1fc86c,function(_0x11d7a2,_0x463fda){if(_0x11d7a2){_0x54ab74(_0x11d7a2);}else if(_0x463fda){if(_0x463fda['AudioStream']instanceof Buffer){fs['writeFile'](_0x44624f,_0x463fda[_0x7e12('0x5')],function(_0x4fa567){if(_0x4fa567){_0x54ab74(_0x4fa567);}else{_0x290063();}});}else{_0x54ab74(new Error(_0x7e12('0x6')));}}else{_0x54ab74(new Error(_0x7e12('0x7')));}});});}module[_0x7e12('0x8')]=function(_0x141d53,_0x386ee7,_0x179673,_0x279c29,_0x167d31,_0x3e87c9,_0x4d8973){var _0x8ff08b=new AWS[(_0x7e12('0x9'))]({'accessKeyId':_0x141d53,'secretAccessKey':_0x386ee7,'region':_0x179673});var _0x5ef988={'Text':_0x167d31,'TextType':_0x3e87c9||_0x7e12('0xa'),'OutputFormat':_0x7e12('0xb'),'VoiceId':_0x279c29};return pollyResult(_0x8ff08b,_0x5ef988,_0x4d8973);};