Built motion from commit 10af8726.|2.6.34
[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 _0xff27=['bluebird','aws-sdk','synthesizeSpeech','AudioStream','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','No\x20data\x20response\x20from\x20aws\x20Polly!','text','mp3'];(function(_0x397cfb,_0xb8f317){var _0x15fed9=function(_0x3eba43){while(--_0x3eba43){_0x397cfb['push'](_0x397cfb['shift']());}};_0x15fed9(++_0xb8f317);}(_0xff27,0xb0));var _0x7ff2=function(_0x2459fd,_0x575d9b){_0x2459fd=_0x2459fd-0x0;var _0x364cd2=_0xff27[_0x2459fd];return _0x364cd2;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0x7ff2('0x0'));var rs=require('randomstring');var AWS=require(_0x7ff2('0x1'));function pollyResult(_0x254e77,_0x12a305,_0x2aa3ee){return new BPromise(function(_0x40adee,_0x2f66e8){_0x254e77[_0x7ff2('0x2')](_0x12a305,function(_0x4b4e1c,_0x387d23){if(_0x4b4e1c){_0x2f66e8(_0x4b4e1c);}else if(_0x387d23){if(_0x387d23[_0x7ff2('0x3')]instanceof Buffer){fs['writeFile'](_0x2aa3ee,_0x387d23[_0x7ff2('0x3')],function(_0x7c22ba){if(_0x7c22ba){_0x2f66e8(_0x7c22ba);}else{_0x40adee();}});}else{_0x2f66e8(new Error(_0x7ff2('0x4')));}}else{_0x2f66e8(new Error(_0x7ff2('0x5')));}});});}module['exports']=function(_0x2702ff,_0x137c35,_0x4e0a9f,_0x26336e,_0x4b4fb7,_0x2bc433,_0x5ea545){var _0x22d403=new AWS['Polly']({'accessKeyId':_0x2702ff,'secretAccessKey':_0x137c35,'region':_0x4e0a9f});var _0x2a0172={'Text':_0x4b4fb7,'TextType':_0x2bc433||_0x7ff2('0x6'),'OutputFormat':_0x7ff2('0x7'),'VoiceId':_0x26336e};return pollyResult(_0x22d403,_0x2a0172,_0x5ea545);};