Built motion from commit 497d3d92.|2.5.43
[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 _0x259f=['exports','aws-sdk','AudioStream','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!'];(function(_0x45e98e,_0x169b60){var _0x374dba=function(_0x597612){while(--_0x597612){_0x45e98e['push'](_0x45e98e['shift']());}};_0x374dba(++_0x169b60);}(_0x259f,0x128));var _0xf259=function(_0x5e5ad1,_0x4b230e){_0x5e5ad1=_0x5e5ad1-0x0;var _0x4ae6ac=_0x259f[_0x5e5ad1];return _0x4ae6ac;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require('bluebird');var rs=require('randomstring');var AWS=require(_0xf259('0x0'));function pollyResult(_0x2222c2,_0x34f248,_0x505b22){return new BPromise(function(_0x5cec90,_0x4ee90d){_0x2222c2['synthesizeSpeech'](_0x34f248,function(_0x429588,_0xd09344){if(_0x429588){_0x4ee90d(_0x429588);}else if(_0xd09344){if(_0xd09344['AudioStream']instanceof Buffer){fs['writeFile'](_0x505b22,_0xd09344[_0xf259('0x1')],function(_0x25dfa1){if(_0x25dfa1){_0x4ee90d(_0x25dfa1);}else{_0x5cec90();}});}else{_0x4ee90d(new Error(_0xf259('0x2')));}}else{_0x4ee90d(new Error(_0xf259('0x3')));}});});}module[_0xf259('0x4')]=function(_0x40bc15,_0x3590c7,_0x2f7018,_0x655143,_0x17ef34,_0xce6963,_0x316820){var _0x3fadc1=new AWS['Polly']({'accessKeyId':_0x40bc15,'secretAccessKey':_0x3590c7,'region':_0x2f7018});var _0x45f6a8={'Text':_0x17ef34,'TextType':_0xce6963||'text','OutputFormat':'mp3','VoiceId':_0x655143};return pollyResult(_0x3fadc1,_0x45f6a8,_0x316820);};