91389fe4400dd22874f83ed4e04d886760848f0e
[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 _0x58b4=['exports','text','mp3','path','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!'];(function(_0x421d83,_0x12285){var _0x418237=function(_0x1c579b){while(--_0x1c579b){_0x421d83['push'](_0x421d83['shift']());}};_0x418237(++_0x12285);}(_0x58b4,0x184));var _0x458b=function(_0x3c41c8,_0x4a9475){_0x3c41c8=_0x3c41c8-0x0;var _0x5baf79=_0x58b4[_0x3c41c8];return _0x5baf79;};'use strict';var fs=require('fs');var path=require(_0x458b('0x0'));var BPromise=require(_0x458b('0x1'));var rs=require(_0x458b('0x2'));var AWS=require(_0x458b('0x3'));function pollyResult(_0x205e39,_0x12d109,_0x5d4400){return new BPromise(function(_0x3c0896,_0x5f375b){_0x205e39[_0x458b('0x4')](_0x12d109,function(_0x71c85a,_0x180bb7){if(_0x71c85a){_0x5f375b(_0x71c85a);}else if(_0x180bb7){if(_0x180bb7[_0x458b('0x5')]instanceof Buffer){fs[_0x458b('0x6')](_0x5d4400,_0x180bb7[_0x458b('0x5')],function(_0x310b27){if(_0x310b27){_0x5f375b(_0x310b27);}else{_0x3c0896();}});}else{_0x5f375b(new Error(_0x458b('0x7')));}}else{_0x5f375b(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x458b('0x8')]=function(_0x3d6524,_0x51f557,_0x3ec119,_0x511f1a,_0x1664e0,_0x15bff6,_0x321a27){var _0x3c01d6=new AWS['Polly']({'accessKeyId':_0x3d6524,'secretAccessKey':_0x51f557,'region':_0x3ec119});var _0x3bba4c={'Text':_0x1664e0,'TextType':_0x15bff6||_0x458b('0x9'),'OutputFormat':_0x458b('0xa'),'VoiceId':_0x511f1a};return pollyResult(_0x3c01d6,_0x3bba4c,_0x321a27);};