Built motion from commit e0fa946e.|2.6.5
[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 _0x67f3=['Invalid\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','mp3','bluebird','synthesizeSpeech','writeFile','AudioStream'];(function(_0x4628db,_0x3258b4){var _0x39ce74=function(_0x4fc718){while(--_0x4fc718){_0x4628db['push'](_0x4628db['shift']());}};_0x39ce74(++_0x3258b4);}(_0x67f3,0x95));var _0x367f=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0x67f3[_0x19950b];return _0x3c6b41;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0x367f('0x0'));var rs=require('randomstring');var AWS=require('aws-sdk');function pollyResult(_0x98d9ed,_0x1b8d33,_0x210c2c){return new BPromise(function(_0x716972,_0x46eb34){_0x98d9ed[_0x367f('0x1')](_0x1b8d33,function(_0x23d936,_0x55252b){if(_0x23d936){_0x46eb34(_0x23d936);}else if(_0x55252b){if(_0x55252b['AudioStream']instanceof Buffer){fs[_0x367f('0x2')](_0x210c2c,_0x55252b[_0x367f('0x3')],function(_0x44d99e){if(_0x44d99e){_0x46eb34(_0x44d99e);}else{_0x716972();}});}else{_0x46eb34(new Error(_0x367f('0x4')));}}else{_0x46eb34(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x367f('0x5')]=function(_0xda8ae3,_0x48d7ff,_0xcdc1f9,_0x1def12,_0x15be21,_0x5769a3,_0x562e43){var _0x3cb899=new AWS[(_0x367f('0x6'))]({'accessKeyId':_0xda8ae3,'secretAccessKey':_0x48d7ff,'region':_0xcdc1f9});var _0x11ccf9={'Text':_0x15be21,'TextType':_0x5769a3||_0x367f('0x7'),'OutputFormat':_0x367f('0x8'),'VoiceId':_0x1def12};return pollyResult(_0x3cb899,_0x11ccf9,_0x562e43);};