5c0ebf07668e4625e507f1fdefcd2e2bc0bb42a0
[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 _0x83fb=['text','bluebird','randomstring','synthesizeSpeech','writeFile','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly'];(function(_0x98a17b,_0x2b6239){var _0x402882=function(_0x4eab1b){while(--_0x4eab1b){_0x98a17b['push'](_0x98a17b['shift']());}};_0x402882(++_0x2b6239);}(_0x83fb,0x99));var _0xb83f=function(_0x490ca0,_0x2894f2){_0x490ca0=_0x490ca0-0x0;var _0x53845c=_0x83fb[_0x490ca0];return _0x53845c;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0xb83f('0x0'));var rs=require(_0xb83f('0x1'));var AWS=require('aws-sdk');function pollyResult(_0x29cb24,_0x1d7fe6,_0x248a7b){return new BPromise(function(_0x4783be,_0x5e1e60){_0x29cb24[_0xb83f('0x2')](_0x1d7fe6,function(_0x419e10,_0x4c4bdb){if(_0x419e10){_0x5e1e60(_0x419e10);}else if(_0x4c4bdb){if(_0x4c4bdb['AudioStream']instanceof Buffer){fs[_0xb83f('0x3')](_0x248a7b,_0x4c4bdb['AudioStream'],function(_0x85c385){if(_0x85c385){_0x5e1e60(_0x85c385);}else{_0x4783be();}});}else{_0x5e1e60(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x5e1e60(new Error(_0xb83f('0x4')));}});});}module[_0xb83f('0x5')]=function(_0x1185b3,_0x5b2342,_0x474f21,_0x2ddd13,_0x5d4122,_0x179005,_0x5d3e57){var _0x562b9f=new AWS[(_0xb83f('0x6'))]({'accessKeyId':_0x1185b3,'secretAccessKey':_0x5b2342,'region':_0x474f21});var _0x2f88fb={'Text':_0x5d4122,'TextType':_0x179005||_0xb83f('0x7'),'OutputFormat':'mp3','VoiceId':_0x2ddd13};return pollyResult(_0x562b9f,_0x2f88fb,_0x5d3e57);};