Built motion from commit (unavailable).|2.5.30
[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 _0xfd9a=['aws-sdk','synthesizeSpeech','writeFile','AudioStream','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','mp3','bluebird'];(function(_0xbcb4bf,_0x5296ed){var _0x3932b3=function(_0x3df0f2){while(--_0x3df0f2){_0xbcb4bf['push'](_0xbcb4bf['shift']());}};_0x3932b3(++_0x5296ed);}(_0xfd9a,0x1d3));var _0xafd9=function(_0x4e1217,_0x45a98a){_0x4e1217=_0x4e1217-0x0;var _0x1ecdce=_0xfd9a[_0x4e1217];return _0x1ecdce;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0xafd9('0x0'));var rs=require('randomstring');var AWS=require(_0xafd9('0x1'));function pollyResult(_0x2cf9d9,_0x241ae5,_0x456771){return new BPromise(function(_0x19637b,_0x3625bb){_0x2cf9d9[_0xafd9('0x2')](_0x241ae5,function(_0xa1c2fc,_0x3ff314){if(_0xa1c2fc){_0x3625bb(_0xa1c2fc);}else if(_0x3ff314){if(_0x3ff314['AudioStream']instanceof Buffer){fs[_0xafd9('0x3')](_0x456771,_0x3ff314[_0xafd9('0x4')],function(_0x1021ed){if(_0x1021ed){_0x3625bb(_0x1021ed);}else{_0x19637b();}});}else{_0x3625bb(new Error(_0xafd9('0x5')));}}else{_0x3625bb(new Error(_0xafd9('0x6')));}});});}module[_0xafd9('0x7')]=function(_0xb1900c,_0x1aca28,_0x534696,_0x2ece84,_0x122d1f,_0x1790a1,_0x476a7d){var _0x49761b=new AWS['Polly']({'accessKeyId':_0xb1900c,'secretAccessKey':_0x1aca28,'region':_0x534696});var _0xda4790={'Text':_0x122d1f,'TextType':_0x1790a1||'text','OutputFormat':_0xafd9('0x8'),'VoiceId':_0x2ece84};return pollyResult(_0x49761b,_0xda4790,_0x476a7d);};