Built motion from commit 25580385.|2.6.2
[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 _0x7970=['text','mp3','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','exports'];(function(_0x18442a,_0x57143d){var _0x2bb33e=function(_0x358b7f){while(--_0x358b7f){_0x18442a['push'](_0x18442a['shift']());}};_0x2bb33e(++_0x57143d);}(_0x7970,0x1ce));var _0x0797=function(_0xee6851,_0x2d132d){_0xee6851=_0xee6851-0x0;var _0x5b37f4=_0x7970[_0xee6851];return _0x5b37f4;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0x0797('0x0'));var rs=require(_0x0797('0x1'));var AWS=require(_0x0797('0x2'));function pollyResult(_0x50af04,_0x4efbe8,_0x3ae873){return new BPromise(function(_0x5724c4,_0x56ff7b){_0x50af04[_0x0797('0x3')](_0x4efbe8,function(_0x2b5367,_0x2f69cb){if(_0x2b5367){_0x56ff7b(_0x2b5367);}else if(_0x2f69cb){if(_0x2f69cb[_0x0797('0x4')]instanceof Buffer){fs[_0x0797('0x5')](_0x3ae873,_0x2f69cb[_0x0797('0x4')],function(_0xf38561){if(_0xf38561){_0x56ff7b(_0xf38561);}else{_0x5724c4();}});}else{_0x56ff7b(new Error(_0x0797('0x6')));}}else{_0x56ff7b(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x0797('0x7')]=function(_0x5df1ad,_0x484f7b,_0x17bdcd,_0x4db319,_0x42131a,_0x3c2c20,_0x1e59e4){var _0xdfed4e=new AWS['Polly']({'accessKeyId':_0x5df1ad,'secretAccessKey':_0x484f7b,'region':_0x17bdcd});var _0x59b9fb={'Text':_0x42131a,'TextType':_0x3c2c20||_0x0797('0x8'),'OutputFormat':_0x0797('0x9'),'VoiceId':_0x4db319};return pollyResult(_0xdfed4e,_0x59b9fb,_0x1e59e4);};