Built motion from commit 1fa89557.|2.6.10
[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 _0xbdb8=['synthesizeSpeech','writeFile','AudioStream','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','path','randomstring'];(function(_0x54a2e4,_0x1ff92c){var _0x4742d0=function(_0x147a6f){while(--_0x147a6f){_0x54a2e4['push'](_0x54a2e4['shift']());}};_0x4742d0(++_0x1ff92c);}(_0xbdb8,0x10c));var _0x8bdb=function(_0x33d7d6,_0x4ea090){_0x33d7d6=_0x33d7d6-0x0;var _0x5a0b80=_0xbdb8[_0x33d7d6];return _0x5a0b80;};'use strict';var fs=require('fs');var path=require(_0x8bdb('0x0'));var BPromise=require('bluebird');var rs=require(_0x8bdb('0x1'));var AWS=require('aws-sdk');function pollyResult(_0x430d03,_0x487b48,_0x1e8a99){return new BPromise(function(_0xb43b2,_0x5c1ab7){_0x430d03[_0x8bdb('0x2')](_0x487b48,function(_0x10bbc7,_0x2b6173){if(_0x10bbc7){_0x5c1ab7(_0x10bbc7);}else if(_0x2b6173){if(_0x2b6173['AudioStream']instanceof Buffer){fs[_0x8bdb('0x3')](_0x1e8a99,_0x2b6173[_0x8bdb('0x4')],function(_0x104a49){if(_0x104a49){_0x5c1ab7(_0x104a49);}else{_0xb43b2();}});}else{_0x5c1ab7(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x5c1ab7(new Error(_0x8bdb('0x5')));}});});}module[_0x8bdb('0x6')]=function(_0x1cc81b,_0x31c3bf,_0x16bc8d,_0xa09901,_0x16099c,_0x57e05,_0xd19ff6){var _0x2de0fa=new AWS[(_0x8bdb('0x7'))]({'accessKeyId':_0x1cc81b,'secretAccessKey':_0x31c3bf,'region':_0x16bc8d});var _0x2a2849={'Text':_0x16099c,'TextType':_0x57e05||_0x8bdb('0x8'),'OutputFormat':'mp3','VoiceId':_0xa09901};return pollyResult(_0x2de0fa,_0x2a2849,_0xd19ff6);};