Built motion from commit 3e059bc2.|2.5.32
[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 _0x1e28=['synthesizeSpeech','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','text','mp3','path','bluebird','aws-sdk'];(function(_0x5ce8b9,_0x5cded8){var _0xe34be0=function(_0xe3d4e5){while(--_0xe3d4e5){_0x5ce8b9['push'](_0x5ce8b9['shift']());}};_0xe34be0(++_0x5cded8);}(_0x1e28,0xfd));var _0x81e2=function(_0x4d79bc,_0x32c905){_0x4d79bc=_0x4d79bc-0x0;var _0x4b4760=_0x1e28[_0x4d79bc];return _0x4b4760;};'use strict';var fs=require('fs');var path=require(_0x81e2('0x0'));var BPromise=require(_0x81e2('0x1'));var rs=require('randomstring');var AWS=require(_0x81e2('0x2'));function pollyResult(_0x486536,_0xa8ca6b,_0x20c34d){return new BPromise(function(_0x3b06fe,_0x5b7dc1){_0x486536[_0x81e2('0x3')](_0xa8ca6b,function(_0x338b1d,_0x36dde8){if(_0x338b1d){_0x5b7dc1(_0x338b1d);}else if(_0x36dde8){if(_0x36dde8['AudioStream']instanceof Buffer){fs[_0x81e2('0x4')](_0x20c34d,_0x36dde8['AudioStream'],function(_0x1ac370){if(_0x1ac370){_0x5b7dc1(_0x1ac370);}else{_0x3b06fe();}});}else{_0x5b7dc1(new Error(_0x81e2('0x5')));}}else{_0x5b7dc1(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module['exports']=function(_0x45d805,_0x484c61,_0x3e475,_0x825212,_0x1817a2,_0x3ce134,_0x98ab03){var _0x5726d6=new AWS['Polly']({'accessKeyId':_0x45d805,'secretAccessKey':_0x484c61,'region':_0x3e475});var _0x2c1ba2={'Text':_0x1817a2,'TextType':_0x3ce134||_0x81e2('0x6'),'OutputFormat':_0x81e2('0x7'),'VoiceId':_0x825212};return pollyResult(_0x5726d6,_0x2c1ba2,_0x98ab03);};