bdf6d279295494e0c71bc6b74fd3eb10bffb0fab
[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 _0xf0d4=['randomstring','synthesizeSpeech','writeFile','AudioStream','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','mp3','path'];(function(_0x2f45ea,_0x15c656){var _0x485a84=function(_0x4a1fe3){while(--_0x4a1fe3){_0x2f45ea['push'](_0x2f45ea['shift']());}};_0x485a84(++_0x15c656);}(_0xf0d4,0x167));var _0x4f0d=function(_0x1bbc08,_0x444008){_0x1bbc08=_0x1bbc08-0x0;var _0x5d825b=_0xf0d4[_0x1bbc08];return _0x5d825b;};'use strict';var fs=require('fs');var path=require(_0x4f0d('0x0'));var BPromise=require('bluebird');var rs=require(_0x4f0d('0x1'));var AWS=require('aws-sdk');function pollyResult(_0x160213,_0x3da84e,_0x138584){return new BPromise(function(_0x129665,_0x42cb38){_0x160213[_0x4f0d('0x2')](_0x3da84e,function(_0x3ab6ef,_0x4962c6){if(_0x3ab6ef){_0x42cb38(_0x3ab6ef);}else if(_0x4962c6){if(_0x4962c6['AudioStream']instanceof Buffer){fs[_0x4f0d('0x3')](_0x138584,_0x4962c6[_0x4f0d('0x4')],function(_0x4ca7ec){if(_0x4ca7ec){_0x42cb38(_0x4ca7ec);}else{_0x129665();}});}else{_0x42cb38(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x42cb38(new Error(_0x4f0d('0x5')));}});});}module[_0x4f0d('0x6')]=function(_0x2b3242,_0x231c3d,_0x1fbd28,_0x5c5a2d,_0x32b835,_0x4353ab,_0x3fb5fd){var _0x5959a0=new AWS[(_0x4f0d('0x7'))]({'accessKeyId':_0x2b3242,'secretAccessKey':_0x231c3d,'region':_0x1fbd28});var _0x13c104={'Text':_0x32b835,'TextType':_0x4353ab||'text','OutputFormat':_0x4f0d('0x8'),'VoiceId':_0x5c5a2d};return pollyResult(_0x5959a0,_0x13c104,_0x3fb5fd);};