Built motion from commit (unavailable).|2.5.14
[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 _0xeea4=['writeFile','exports','Polly','text','mp3','aws-sdk','synthesizeSpeech','AudioStream'];(function(_0x39feb4,_0x4e8569){var _0x154ea4=function(_0xa2b85){while(--_0xa2b85){_0x39feb4['push'](_0x39feb4['shift']());}};_0x154ea4(++_0x4e8569);}(_0xeea4,0x14d));var _0x4eea=function(_0x2e78b7,_0x4da7aa){_0x2e78b7=_0x2e78b7-0x0;var _0x3fbdea=_0xeea4[_0x2e78b7];return _0x3fbdea;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require('bluebird');var rs=require('randomstring');var AWS=require(_0x4eea('0x0'));function pollyResult(_0x14f6fa,_0x4454d5,_0x39c978){return new BPromise(function(_0x2eaade,_0x46abc5){_0x14f6fa[_0x4eea('0x1')](_0x4454d5,function(_0x17b05a,_0x1bd0dd){if(_0x17b05a){_0x46abc5(_0x17b05a);}else if(_0x1bd0dd){if(_0x1bd0dd[_0x4eea('0x2')]instanceof Buffer){fs[_0x4eea('0x3')](_0x39c978,_0x1bd0dd[_0x4eea('0x2')],function(_0x19c92e){if(_0x19c92e){_0x46abc5(_0x19c92e);}else{_0x2eaade();}});}else{_0x46abc5(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x46abc5(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x4eea('0x4')]=function(_0x2d581a,_0x1ac1b1,_0x316618,_0x1492d7,_0x201089,_0x1c641d,_0x425e6c){var _0x2194d6=new AWS[(_0x4eea('0x5'))]({'accessKeyId':_0x2d581a,'secretAccessKey':_0x1ac1b1,'region':_0x316618});var _0x2b62db={'Text':_0x201089,'TextType':_0x1c641d||_0x4eea('0x6'),'OutputFormat':_0x4eea('0x7'),'VoiceId':_0x1492d7};return pollyResult(_0x2194d6,_0x2b62db,_0x425e6c);};