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 _0xa3e3=['mp3','path','randomstring','synthesizeSpeech','AudioStream','No\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text'];(function(_0xb7cb72,_0x19d391){var _0x4b7570=function(_0x5a4a93){while(--_0x5a4a93){_0xb7cb72['push'](_0xb7cb72['shift']());}};_0x4b7570(++_0x19d391);}(_0xa3e3,0x12a));var _0x3a3e=function(_0x5be1a3,_0x4de0c6){_0x5be1a3=_0x5be1a3-0x0;var _0x37c91b=_0xa3e3[_0x5be1a3];return _0x37c91b;};'use strict';var fs=require('fs');var path=require(_0x3a3e('0x0'));var BPromise=require('bluebird');var rs=require(_0x3a3e('0x1'));var AWS=require('aws-sdk');function pollyResult(_0x5f4d14,_0x220ab4,_0x5cfc15){return new BPromise(function(_0x2a2a8a,_0x54b0c5){_0x5f4d14[_0x3a3e('0x2')](_0x220ab4,function(_0x2f6896,_0x1befdd){if(_0x2f6896){_0x54b0c5(_0x2f6896);}else if(_0x1befdd){if(_0x1befdd[_0x3a3e('0x3')]instanceof Buffer){fs['writeFile'](_0x5cfc15,_0x1befdd['AudioStream'],function(_0x553987){if(_0x553987){_0x54b0c5(_0x553987);}else{_0x2a2a8a();}});}else{_0x54b0c5(new Error('Invalid\x20data\x20response\x20from\x20aws\x20Polly!'));}}else{_0x54b0c5(new Error(_0x3a3e('0x4')));}});});}module[_0x3a3e('0x5')]=function(_0x149326,_0x431c9f,_0x4f0c86,_0x2fe39a,_0x971fbd,_0x75b438,_0xcecb24){var _0x430314=new AWS[(_0x3a3e('0x6'))]({'accessKeyId':_0x149326,'secretAccessKey':_0x431c9f,'region':_0x4f0c86});var _0x1a68ac={'Text':_0x971fbd,'TextType':_0x75b438||_0x3a3e('0x7'),'OutputFormat':_0x3a3e('0x8'),'VoiceId':_0x2fe39a};return pollyResult(_0x430314,_0x1a68ac,_0xcecb24);};