Built motion from commit (unavailable).|2.5.2
[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 _0x950d=['randomstring','aws-sdk','synthesizeSpeech','AudioStream','writeFile','No\x20data\x20response\x20from\x20aws\x20Polly!','Polly','mp3','path'];(function(_0x19e35c,_0x29cd1e){var _0x3e1fe8=function(_0x17258b){while(--_0x17258b){_0x19e35c['push'](_0x19e35c['shift']());}};_0x3e1fe8(++_0x29cd1e);}(_0x950d,0xd7));var _0xd950=function(_0xbb091,_0x3fe7ee){_0xbb091=_0xbb091-0x0;var _0x467a04=_0x950d[_0xbb091];return _0x467a04;};'use strict';var fs=require('fs');var path=require(_0xd950('0x0'));var BPromise=require('bluebird');var rs=require(_0xd950('0x1'));var AWS=require(_0xd950('0x2'));function pollyResult(_0x5861c7,_0x5d8fab,_0x58256d){return new BPromise(function(_0x4a1dec,_0x4aaae7){_0x5861c7[_0xd950('0x3')](_0x5d8fab,function(_0x4cfdb6,_0x1a3e30){if(_0x4cfdb6){_0x4aaae7(_0x4cfdb6);}else if(_0x1a3e30){if(_0x1a3e30[_0xd950('0x4')]instanceof Buffer){fs[_0xd950('0x5')](_0x58256d,_0x1a3e30[_0xd950('0x4')],function(_0x2948e4){if(_0x2948e4){_0x4aaae7(_0x2948e4);}else{_0x4a1dec();}});}else{_0x4aaae7(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x4aaae7(new Error(_0xd950('0x6')));}});});}module['exports']=function(_0x15ba93,_0x4f8022,_0x327b03,_0x39d5ae,_0x267c7e,_0x775ddd,_0x141e8f){var _0x437b62=new AWS[(_0xd950('0x7'))]({'accessKeyId':_0x15ba93,'secretAccessKey':_0x4f8022,'region':_0x327b03});var _0x23ba73={'Text':_0x267c7e,'TextType':_0x775ddd||'text','OutputFormat':_0xd950('0x8'),'VoiceId':_0x39d5ae};return pollyResult(_0x437b62,_0x23ba73,_0x141e8f);};