Built motion from commit 3c2ce842.|2.6.31
[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 _0x6032=['synthesizeSpeech','AudioStream','exports','text','mp3','path','bluebird','randomstring','aws-sdk'];(function(_0x561eb7,_0x250764){var _0xb5c0be=function(_0xf2a26d){while(--_0xf2a26d){_0x561eb7['push'](_0x561eb7['shift']());}};_0xb5c0be(++_0x250764);}(_0x6032,0x191));var _0x2603=function(_0x223643,_0x111fcb){_0x223643=_0x223643-0x0;var _0x6f8006=_0x6032[_0x223643];return _0x6f8006;};'use strict';var fs=require('fs');var path=require(_0x2603('0x0'));var BPromise=require(_0x2603('0x1'));var rs=require(_0x2603('0x2'));var AWS=require(_0x2603('0x3'));function pollyResult(_0x2a39ce,_0x21f293,_0x3f6d23){return new BPromise(function(_0x95a71,_0x26432b){_0x2a39ce[_0x2603('0x4')](_0x21f293,function(_0x4dd6ad,_0x3b09a3){if(_0x4dd6ad){_0x26432b(_0x4dd6ad);}else if(_0x3b09a3){if(_0x3b09a3['AudioStream']instanceof Buffer){fs['writeFile'](_0x3f6d23,_0x3b09a3[_0x2603('0x5')],function(_0x3f0e0c){if(_0x3f0e0c){_0x26432b(_0x3f0e0c);}else{_0x95a71();}});}else{_0x26432b(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x26432b(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x2603('0x6')]=function(_0x5d9960,_0x181984,_0x5ebc61,_0x5e3c59,_0x1768ce,_0x559f28,_0xc55a2d){var _0x5699f6=new AWS['Polly']({'accessKeyId':_0x5d9960,'secretAccessKey':_0x181984,'region':_0x5ebc61});var _0xa75865={'Text':_0x1768ce,'TextType':_0x559f28||_0x2603('0x7'),'OutputFormat':_0x2603('0x8'),'VoiceId':_0x5e3c59};return pollyResult(_0x5699f6,_0xa75865,_0xc55a2d);};