1eea4b73210dd497e13198f5efed333551349529
[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 _0xec21=['No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','bluebird','aws-sdk','synthesizeSpeech','writeFile','AudioStream'];(function(_0x9a6891,_0x5e1eff){var _0x831b01=function(_0x9135a3){while(--_0x9135a3){_0x9a6891['push'](_0x9a6891['shift']());}};_0x831b01(++_0x5e1eff);}(_0xec21,0x15a));var _0x1ec2=function(_0x5452c9,_0xc7ea83){_0x5452c9=_0x5452c9-0x0;var _0x2ca4e1=_0xec21[_0x5452c9];return _0x2ca4e1;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0x1ec2('0x0'));var rs=require('randomstring');var AWS=require(_0x1ec2('0x1'));function pollyResult(_0x341b76,_0x59a378,_0x42e45b){return new BPromise(function(_0x3f01a1,_0x196cd1){_0x341b76[_0x1ec2('0x2')](_0x59a378,function(_0x12bfd9,_0x536800){if(_0x12bfd9){_0x196cd1(_0x12bfd9);}else if(_0x536800){if(_0x536800['AudioStream']instanceof Buffer){fs[_0x1ec2('0x3')](_0x42e45b,_0x536800[_0x1ec2('0x4')],function(_0x554413){if(_0x554413){_0x196cd1(_0x554413);}else{_0x3f01a1();}});}else{_0x196cd1(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x196cd1(new Error(_0x1ec2('0x5')));}});});}module[_0x1ec2('0x6')]=function(_0x3b6764,_0x10ad5f,_0x453de9,_0x1750b8,_0x515e4e,_0x5e15dc,_0xb3df5){var _0x4b4346=new AWS[(_0x1ec2('0x7'))]({'accessKeyId':_0x3b6764,'secretAccessKey':_0x10ad5f,'region':_0x453de9});var _0x5bdabf={'Text':_0x515e4e,'TextType':_0x5e15dc||_0x1ec2('0x8'),'OutputFormat':'mp3','VoiceId':_0x1750b8};return pollyResult(_0x4b4346,_0x5bdabf,_0xb3df5);};