Built motion from commit b5413ace.|2.6.9
[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 _0x9353=['Invalid\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','mp3','path','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream'];(function(_0x1c156e,_0x3263a6){var _0x58fc22=function(_0x42f1eb){while(--_0x42f1eb){_0x1c156e['push'](_0x1c156e['shift']());}};_0x58fc22(++_0x3263a6);}(_0x9353,0x1d0));var _0x3935=function(_0x5d155b,_0x13ddf5){_0x5d155b=_0x5d155b-0x0;var _0x4d0893=_0x9353[_0x5d155b];return _0x4d0893;};'use strict';var fs=require('fs');var path=require(_0x3935('0x0'));var BPromise=require(_0x3935('0x1'));var rs=require(_0x3935('0x2'));var AWS=require(_0x3935('0x3'));function pollyResult(_0xfe9dd5,_0x196a2e,_0x5a5bf0){return new BPromise(function(_0x5011d2,_0x27d39b){_0xfe9dd5[_0x3935('0x4')](_0x196a2e,function(_0x1061f8,_0x21b46f){if(_0x1061f8){_0x27d39b(_0x1061f8);}else if(_0x21b46f){if(_0x21b46f[_0x3935('0x5')]instanceof Buffer){fs['writeFile'](_0x5a5bf0,_0x21b46f[_0x3935('0x5')],function(_0xb123e3){if(_0xb123e3){_0x27d39b(_0xb123e3);}else{_0x5011d2();}});}else{_0x27d39b(new Error(_0x3935('0x6')));}}else{_0x27d39b(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0x3935('0x7')]=function(_0x2d770a,_0x45feaf,_0x2b3fb3,_0x3adacc,_0x1fff09,_0x44096a,_0x4e81cc){var _0x573d76=new AWS[(_0x3935('0x8'))]({'accessKeyId':_0x2d770a,'secretAccessKey':_0x45feaf,'region':_0x2b3fb3});var _0x55cdac={'Text':_0x1fff09,'TextType':_0x44096a||'text','OutputFormat':_0x3935('0x9'),'VoiceId':_0x3adacc};return pollyResult(_0x573d76,_0x55cdac,_0x4e81cc);};