Built motion from commit d301b742.|2.6.29
[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 _0xae09=['Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','mp3','bluebird','randomstring','aws-sdk','synthesizeSpeech','writeFile'];(function(_0xb0f7c3,_0x4eae95){var _0x28ea68=function(_0x4395a7){while(--_0x4395a7){_0xb0f7c3['push'](_0xb0f7c3['shift']());}};_0x28ea68(++_0x4eae95);}(_0xae09,0xb9));var _0x9ae0=function(_0x15a004,_0x371f70){_0x15a004=_0x15a004-0x0;var _0xaf8f1d=_0xae09[_0x15a004];return _0xaf8f1d;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0x9ae0('0x0'));var rs=require(_0x9ae0('0x1'));var AWS=require(_0x9ae0('0x2'));function pollyResult(_0x87e082,_0x892b27,_0x51dfec){return new BPromise(function(_0x29dbde,_0x12e24a){_0x87e082[_0x9ae0('0x3')](_0x892b27,function(_0x425952,_0x56441b){if(_0x425952){_0x12e24a(_0x425952);}else if(_0x56441b){if(_0x56441b['AudioStream']instanceof Buffer){fs[_0x9ae0('0x4')](_0x51dfec,_0x56441b['AudioStream'],function(_0x16619c){if(_0x16619c){_0x12e24a(_0x16619c);}else{_0x29dbde();}});}else{_0x12e24a(new Error(_0x9ae0('0x5')));}}else{_0x12e24a(new Error(_0x9ae0('0x6')));}});});}module[_0x9ae0('0x7')]=function(_0x27ed3f,_0x29dd9f,_0x13de66,_0xb0ee5,_0x4c0447,_0x1ccced,_0x3a477c){var _0x586d7e=new AWS[(_0x9ae0('0x8'))]({'accessKeyId':_0x27ed3f,'secretAccessKey':_0x29dd9f,'region':_0x13de66});var _0x5311c5={'Text':_0x4c0447,'TextType':_0x1ccced||'text','OutputFormat':_0x9ae0('0x9'),'VoiceId':_0xb0ee5};return pollyResult(_0x586d7e,_0x5311c5,_0x3a477c);};