9a495600657235b625e471a5afd082755b81b90c
[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 _0x7a9a=['Invalid\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','path','bluebird','randomstring','aws-sdk','synthesizeSpeech','AudioStream'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x7a9a,0x1ee));var _0xa7a9=function(_0xfc96f6,_0x324451){_0xfc96f6=_0xfc96f6-0x0;var _0x12c4ed=_0x7a9a[_0xfc96f6];return _0x12c4ed;};'use strict';var fs=require('fs');var path=require(_0xa7a9('0x0'));var BPromise=require(_0xa7a9('0x1'));var rs=require(_0xa7a9('0x2'));var AWS=require(_0xa7a9('0x3'));function pollyResult(_0x5de3db,_0x30fd3c,_0x26f349){return new BPromise(function(_0x3d2e97,_0x323b6a){_0x5de3db[_0xa7a9('0x4')](_0x30fd3c,function(_0x29eb26,_0x448971){if(_0x29eb26){_0x323b6a(_0x29eb26);}else if(_0x448971){if(_0x448971[_0xa7a9('0x5')]instanceof Buffer){fs['writeFile'](_0x26f349,_0x448971[_0xa7a9('0x5')],function(_0x4ae4d1){if(_0x4ae4d1){_0x323b6a(_0x4ae4d1);}else{_0x3d2e97();}});}else{_0x323b6a(new Error(_0xa7a9('0x6')));}}else{_0x323b6a(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0xa7a9('0x7')]=function(_0x539562,_0x49878e,_0x113bf8,_0x3d8bd7,_0x27c3c9,_0x293117,_0x11f1f3){var _0x49ef7d=new AWS[(_0xa7a9('0x8'))]({'accessKeyId':_0x539562,'secretAccessKey':_0x49878e,'region':_0x113bf8});var _0x383517={'Text':_0x27c3c9,'TextType':_0x293117||_0xa7a9('0x9'),'OutputFormat':'mp3','VoiceId':_0x3d8bd7};return pollyResult(_0x49ef7d,_0x383517,_0x11f1f3);};