Built motion from commit 47436d59.|2.6.7
[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 _0xf7a4=['exports','Polly','text','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!'];(function(_0x1a014b,_0x48acae){var _0x462258=function(_0x1473be){while(--_0x1473be){_0x1a014b['push'](_0x1a014b['shift']());}};_0x462258(++_0x48acae);}(_0xf7a4,0x66));var _0x4f7a=function(_0x4a9fb1,_0x273043){_0x4a9fb1=_0x4a9fb1-0x0;var _0x348672=_0xf7a4[_0x4a9fb1];return _0x348672;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require('bluebird');var rs=require(_0x4f7a('0x0'));var AWS=require(_0x4f7a('0x1'));function pollyResult(_0x33a972,_0x8f1563,_0x4dce46){return new BPromise(function(_0xa3ab74,_0x2b78f2){_0x33a972[_0x4f7a('0x2')](_0x8f1563,function(_0x280596,_0xd6cb06){if(_0x280596){_0x2b78f2(_0x280596);}else if(_0xd6cb06){if(_0xd6cb06[_0x4f7a('0x3')]instanceof Buffer){fs[_0x4f7a('0x4')](_0x4dce46,_0xd6cb06[_0x4f7a('0x3')],function(_0x2bfac6){if(_0x2bfac6){_0x2b78f2(_0x2bfac6);}else{_0xa3ab74();}});}else{_0x2b78f2(new Error(_0x4f7a('0x5')));}}else{_0x2b78f2(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x4f7a('0x6')]=function(_0x48c27b,_0x3eead9,_0x51b54b,_0x413995,_0x250d1e,_0x6d0831,_0x5b35a4){var _0x2e68ae=new AWS[(_0x4f7a('0x7'))]({'accessKeyId':_0x48c27b,'secretAccessKey':_0x3eead9,'region':_0x51b54b});var _0x28a9ab={'Text':_0x250d1e,'TextType':_0x6d0831||_0x4f7a('0x8'),'OutputFormat':'mp3','VoiceId':_0x413995};return pollyResult(_0x2e68ae,_0x28a9ab,_0x5b35a4);};