230eb86a0d253699ebba791a86bef411538afd86
[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 _0xf4fd=['writeFile','Invalid\x20data\x20response\x20from\x20aws\x20Polly!','exports','Polly','text','mp3','bluebird','randomstring','aws-sdk','AudioStream'];(function(_0x20b8d,_0x471e78){var _0x44b833=function(_0xcfc880){while(--_0xcfc880){_0x20b8d['push'](_0x20b8d['shift']());}};_0x44b833(++_0x471e78);}(_0xf4fd,0xe2));var _0xdf4f=function(_0x3e2cd5,_0x3b5dc3){_0x3e2cd5=_0x3e2cd5-0x0;var _0x550e8b=_0xf4fd[_0x3e2cd5];return _0x550e8b;};'use strict';var fs=require('fs');var path=require('path');var BPromise=require(_0xdf4f('0x0'));var rs=require(_0xdf4f('0x1'));var AWS=require(_0xdf4f('0x2'));function pollyResult(_0xdc59a2,_0x357cb0,_0x4e3219){return new BPromise(function(_0xa1cd0a,_0x3e2e7a){_0xdc59a2['synthesizeSpeech'](_0x357cb0,function(_0x3cb26f,_0x2767dc){if(_0x3cb26f){_0x3e2e7a(_0x3cb26f);}else if(_0x2767dc){if(_0x2767dc[_0xdf4f('0x3')]instanceof Buffer){fs[_0xdf4f('0x4')](_0x4e3219,_0x2767dc[_0xdf4f('0x3')],function(_0x16102b){if(_0x16102b){_0x3e2e7a(_0x16102b);}else{_0xa1cd0a();}});}else{_0x3e2e7a(new Error(_0xdf4f('0x5')));}}else{_0x3e2e7a(new Error('No\x20data\x20response\x20from\x20aws\x20Polly!'));}});});}module[_0xdf4f('0x6')]=function(_0x810574,_0x46e34a,_0x26babe,_0x579048,_0x4c2ae3,_0x586f5e,_0x181ea7){var _0x6b3278=new AWS[(_0xdf4f('0x7'))]({'accessKeyId':_0x810574,'secretAccessKey':_0x46e34a,'region':_0x26babe});var _0x38cdea={'Text':_0x4c2ae3,'TextType':_0x586f5e||_0xdf4f('0x8'),'OutputFormat':_0xdf4f('0x9'),'VoiceId':_0x579048};return pollyResult(_0x6b3278,_0x38cdea,_0x181ea7);};