Built motion from commit 9d0783e6.|2.6.13
[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 _0xcf40=['Invalid\x20data\x20response\x20from\x20aws\x20Polly!','Polly','text','mp3','path','randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile'];(function(_0x378891,_0x4e3e16){var _0xfbfda2=function(_0x3b7681){while(--_0x3b7681){_0x378891['push'](_0x378891['shift']());}};_0xfbfda2(++_0x4e3e16);}(_0xcf40,0x130));var _0x0cf4=function(_0xd734b9,_0x51e11b){_0xd734b9=_0xd734b9-0x0;var _0x59edd9=_0xcf40[_0xd734b9];return _0x59edd9;};'use strict';var fs=require('fs');var path=require(_0x0cf4('0x0'));var BPromise=require('bluebird');var rs=require(_0x0cf4('0x1'));var AWS=require(_0x0cf4('0x2'));function pollyResult(_0x548162,_0xcd86fc,_0x10b2ec){return new BPromise(function(_0x1bd852,_0x1bc84d){_0x548162[_0x0cf4('0x3')](_0xcd86fc,function(_0x2c84e1,_0x4d0552){if(_0x2c84e1){_0x1bc84d(_0x2c84e1);}else if(_0x4d0552){if(_0x4d0552[_0x0cf4('0x4')]instanceof Buffer){fs[_0x0cf4('0x5')](_0x10b2ec,_0x4d0552['AudioStream'],function(_0x3764c2){if(_0x3764c2){_0x1bc84d(_0x3764c2);}else{_0x1bd852();}});}else{_0x1bc84d(new Error(_0x0cf4('0x6')));}}else{_0x1bc84d(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module['exports']=function(_0x160e8b,_0x454246,_0x12caf6,_0x7cff3f,_0x44b6f3,_0x515f41,_0xb76020){var _0x2cf8dc=new AWS[(_0x0cf4('0x7'))]({'accessKeyId':_0x160e8b,'secretAccessKey':_0x454246,'region':_0x12caf6});var _0x18f99a={'Text':_0x44b6f3,'TextType':_0x515f41||_0x0cf4('0x8'),'OutputFormat':_0x0cf4('0x9'),'VoiceId':_0x7cff3f};return pollyResult(_0x2cf8dc,_0x18f99a,_0xb76020);};