Built motion from commit ffdca78c.|2.6.24
[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 _0xef1b=['mp3','bluebird','synthesizeSpeech','AudioStream','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text'];(function(_0x1bfd13,_0x1b1b17){var _0x485cfb=function(_0x22aa75){while(--_0x22aa75){_0x1bfd13['push'](_0x1bfd13['shift']());}};_0x485cfb(++_0x1b1b17);}(_0xef1b,0x1c3));var _0xbef1=function(_0x1a4801,_0x55f4fd){_0x1a4801=_0x1a4801-0x0;var _0x5654f6=_0xef1b[_0x1a4801];return _0x5654f6;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0xbef1('0x0'));var rs=require('randomstring');var AWS=require('aws-sdk');function pollyResult(_0x13e289,_0x299275,_0x16c7d0){return new BPromise(function(_0x523efe,_0x2e7c2b){_0x13e289[_0xbef1('0x1')](_0x299275,function(_0x1eb453,_0x11d26f){if(_0x1eb453){_0x2e7c2b(_0x1eb453);}else if(_0x11d26f){if(_0x11d26f[_0xbef1('0x2')]instanceof Buffer){fs[_0xbef1('0x3')](_0x16c7d0,_0x11d26f[_0xbef1('0x2')],function(_0x481771){if(_0x481771){_0x2e7c2b(_0x481771);}else{_0x523efe();}});}else{_0x2e7c2b(new Error(_0xbef1('0x4')));}}else{_0x2e7c2b(new Error(_0xbef1('0x5')));}});});}module[_0xbef1('0x6')]=function(_0x11ddc5,_0x4e0c70,_0x3ad677,_0x16ff43,_0x571ded,_0x8c18a1,_0x4385de){var _0x4d4a3f=new AWS[(_0xbef1('0x7'))]({'accessKeyId':_0x11ddc5,'secretAccessKey':_0x4e0c70,'region':_0x3ad677});var _0x2baa0e={'Text':_0x571ded,'TextType':_0x8c18a1||_0xbef1('0x8'),'OutputFormat':_0xbef1('0x9'),'VoiceId':_0x16ff43};return pollyResult(_0x4d4a3f,_0x2baa0e,_0x4385de);};