17407691725a0c6f2e9485d357cbeb8a4eb23bb4
[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 _0x44e6=['path','bluebird','aws-sdk','AudioStream','writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','text','mp3'];(function(_0x4a450a,_0x54d42f){var _0x28baf9=function(_0x5cb70a){while(--_0x5cb70a){_0x4a450a['push'](_0x4a450a['shift']());}};_0x28baf9(++_0x54d42f);}(_0x44e6,0x18c));var _0x644e=function(_0x2be8fc,_0x398f30){_0x2be8fc=_0x2be8fc-0x0;var _0x1319a9=_0x44e6[_0x2be8fc];return _0x1319a9;};'use strict';var fs=require('fs');var path=require(_0x644e('0x0'));var BPromise=require(_0x644e('0x1'));var rs=require('randomstring');var AWS=require(_0x644e('0x2'));function pollyResult(_0x5234d8,_0x12ba59,_0x200aca){return new BPromise(function(_0x2d475c,_0xc72379){_0x5234d8['synthesizeSpeech'](_0x12ba59,function(_0x99a5c,_0x4a796b){if(_0x99a5c){_0xc72379(_0x99a5c);}else if(_0x4a796b){if(_0x4a796b[_0x644e('0x3')]instanceof Buffer){fs[_0x644e('0x4')](_0x200aca,_0x4a796b[_0x644e('0x3')],function(_0x36cc93){if(_0x36cc93){_0xc72379(_0x36cc93);}else{_0x2d475c();}});}else{_0xc72379(new Error(_0x644e('0x5')));}}else{_0xc72379(new Error(_0x644e('0x6')));}});});}module['exports']=function(_0x4b6e82,_0x3fe845,_0x22a33f,_0x5221ab,_0x16bec9,_0x1a8d07,_0x147c64){var _0x3dc169=new AWS['Polly']({'accessKeyId':_0x4b6e82,'secretAccessKey':_0x3fe845,'region':_0x22a33f});var _0x1c8514={'Text':_0x16bec9,'TextType':_0x1a8d07||_0x644e('0x7'),'OutputFormat':_0x644e('0x8'),'VoiceId':_0x5221ab};return pollyResult(_0x3dc169,_0x1c8514,_0x147c64);};