cf1e3ec834faa33c8687d4ae59ec8a7d964c79c1
[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 _0x2c35=['mp3','path','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream','exports','text'];(function(_0x436961,_0x1bcd3b){var _0x32ad84=function(_0x4493c4){while(--_0x4493c4){_0x436961['push'](_0x436961['shift']());}};_0x32ad84(++_0x1bcd3b);}(_0x2c35,0x1de));var _0x52c3=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x2c35[_0x3dd15e];return _0x231fd0;};'use strict';var fs=require('fs');var path=require(_0x52c3('0x0'));var BPromise=require(_0x52c3('0x1'));var rs=require(_0x52c3('0x2'));var AWS=require(_0x52c3('0x3'));function pollyResult(_0x5c3681,_0x3561c1,_0x351d34){return new BPromise(function(_0x504f79,_0x488850){_0x5c3681[_0x52c3('0x4')](_0x3561c1,function(_0x433ad8,_0x553327){if(_0x433ad8){_0x488850(_0x433ad8);}else if(_0x553327){if(_0x553327['AudioStream']instanceof Buffer){fs['writeFile'](_0x351d34,_0x553327[_0x52c3('0x5')],function(_0x26a68c){if(_0x26a68c){_0x488850(_0x26a68c);}else{_0x504f79();}});}else{_0x488850(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x488850(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x52c3('0x6')]=function(_0x1f8e45,_0x1a9c80,_0x4bc263,_0x378da8,_0x4211be,_0x3e0084,_0x23e48b){var _0x5f34fa=new AWS['Polly']({'accessKeyId':_0x1f8e45,'secretAccessKey':_0x1a9c80,'region':_0x4bc263});var _0xbdbdce={'Text':_0x4211be,'TextType':_0x3e0084||_0x52c3('0x7'),'OutputFormat':_0x52c3('0x8'),'VoiceId':_0x378da8};return pollyResult(_0x5f34fa,_0xbdbdce,_0x23e48b);};