1c42c02b7eeee903ce1d2861a43d4d40a334df6b
[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 _0x67a6=['bluebird','randomstring','aws-sdk','synthesizeSpeech','writeFile','AudioStream','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','Polly','text','mp3','path'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x67a6,0x112));var _0x667a=function(_0x460150,_0x232949){_0x460150=_0x460150-0x0;var _0x340677=_0x67a6[_0x460150];return _0x340677;};'use strict';var fs=require('fs');var path=require(_0x667a('0x0'));var BPromise=require(_0x667a('0x1'));var rs=require(_0x667a('0x2'));var AWS=require(_0x667a('0x3'));function pollyResult(_0x3010fd,_0x461ae0,_0x58eab0){return new BPromise(function(_0xf4bf5e,_0x1708ae){_0x3010fd[_0x667a('0x4')](_0x461ae0,function(_0x4d664b,_0x252f0b){if(_0x4d664b){_0x1708ae(_0x4d664b);}else if(_0x252f0b){if(_0x252f0b['AudioStream']instanceof Buffer){fs[_0x667a('0x5')](_0x58eab0,_0x252f0b[_0x667a('0x6')],function(_0x55c87c){if(_0x55c87c){_0x1708ae(_0x55c87c);}else{_0xf4bf5e();}});}else{_0x1708ae(new Error(_0x667a('0x7')));}}else{_0x1708ae(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module['exports']=function(_0x5502f2,_0x176fbe,_0x2b20e4,_0x1e62d0,_0x3e54b7,_0x4ed9f5,_0x34a14b){var _0x3f6930=new AWS[(_0x667a('0x8'))]({'accessKeyId':_0x5502f2,'secretAccessKey':_0x176fbe,'region':_0x2b20e4});var _0x10aa79={'Text':_0x3e54b7,'TextType':_0x4ed9f5||_0x667a('0x9'),'OutputFormat':_0x667a('0xa'),'VoiceId':_0x1e62d0};return pollyResult(_0x3f6930,_0x10aa79,_0x34a14b);};