2658b367f20e5feea2d6877ffddbb2089db284cf
[motion2.git] / server / services / agi / scripts / google / asr / 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 _0xc112=['https://speech.googleapis.com','string','length','filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','undefined','readFileSync','toString','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird'];(function(_0x13b8f3,_0x442821){var _0x1a6d06=function(_0x5126f2){while(--_0x5126f2){_0x13b8f3['push'](_0x13b8f3['shift']());}};_0x1a6d06(++_0x442821);}(_0xc112,0xec));var _0x2c11=function(_0x5dd5c0,_0x34c079){_0x5dd5c0=_0x5dd5c0-0x0;var _0x33f9c0=_0xc112[_0x5dd5c0];return _0x33f9c0;};'use strict';var url=require(_0x2c11('0x0'));var BPromise=require(_0x2c11('0x1'));var fs=require('fs');var host=_0x2c11('0x2');module['exports']=function(_0x8542d8,_0x40da2e,_0x26e2a3){return new BPromise(function(_0x170832,_0xaa8492){var _0x3a1cda;if(typeof _0x8542d8!==_0x2c11('0x3')||_0x8542d8[_0x2c11('0x4')]===0x0){return _0xaa8492(_0x2c11('0x5'));}if(typeof _0x40da2e!=='string'||_0x40da2e['length']===0x0){return _0xaa8492(_0x2c11('0x6'));}if(typeof _0x26e2a3!==_0x2c11('0x7')&&(typeof _0x26e2a3!==_0x2c11('0x3')||_0x26e2a3[_0x2c11('0x4')]===0x0)){return _0xaa8492('lang\x20should\x20be\x20a\x20string');}try{_0x3a1cda=fs[_0x2c11('0x8')](_0x8542d8)[_0x2c11('0x9')]('base64');}catch(_0xa32d3f){return _0xaa8492(_0xa32d3f);}return _0x170832({'method':_0x2c11('0xa'),'uri':host+_0x2c11('0xb')+_0x40da2e,'body':{'config':{'encoding':_0x2c11('0xc'),'sampleRateHertz':_0x2c11('0xd'),'languageCode':_0x26e2a3},'audio':{'content':_0x3a1cda}},'json':!![]});});};