eefc8b3260551457c55b26edf6c5d5623ade0114
[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 _0x1efe=['synthesizeSpeech','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','text','mp3','randomstring','aws-sdk'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x1efe,0xbb));var _0xe1ef=function(_0xa8883,_0x1f107f){_0xa8883=_0xa8883-0x0;var _0x479426=_0x1efe[_0xa8883];return _0x479426;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require('bluebird');var rs=require(_0xe1ef('0x0'));var AWS=require(_0xe1ef('0x1'));function pollyResult(_0x1e854c,_0x6a723b,_0x43ef85){return new BPromise(function(_0x3efcc7,_0x3106ee){_0x1e854c[_0xe1ef('0x2')](_0x6a723b,function(_0x48f9c8,_0x633ba8){if(_0x48f9c8){_0x3106ee(_0x48f9c8);}else if(_0x633ba8){if(_0x633ba8['AudioStream']instanceof Buffer){fs[_0xe1ef('0x3')](_0x43ef85,_0x633ba8['AudioStream'],function(_0x717215){if(_0x717215){_0x3106ee(_0x717215);}else{_0x3efcc7();}});}else{_0x3106ee(new Error(_0xe1ef('0x4')));}}else{_0x3106ee(new Error(_0xe1ef('0x5')));}});});}module[_0xe1ef('0x6')]=function(_0x461e21,_0x2dc2ec,_0x4e0be7,_0x14fa51,_0xdd3a39,_0x5043d9,_0x406072){var _0xe2d2df=new AWS['Polly']({'accessKeyId':_0x461e21,'secretAccessKey':_0x2dc2ec,'region':_0x4e0be7});var _0x171051={'Text':_0xdd3a39,'TextType':_0x5043d9||_0xe1ef('0x7'),'OutputFormat':_0xe1ef('0x8'),'VoiceId':_0x14fa51};return pollyResult(_0xe2d2df,_0x171051,_0x406072);};