10c404cdf5bf2cfbac939d78532ab7f1fa3f19cc
[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 _0x2fd3=['LINEAR16','8000','url','bluebird','https://speech.googleapis.com','length','string','key\x20should\x20be\x20a\x20string','lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','POST'];(function(_0x519756,_0x288785){var _0x37047e=function(_0x3d64a7){while(--_0x3d64a7){_0x519756['push'](_0x519756['shift']());}};_0x37047e(++_0x288785);}(_0x2fd3,0x1af));var _0x32fd=function(_0x22ebfe,_0x2c603e){_0x22ebfe=_0x22ebfe-0x0;var _0x31d930=_0x2fd3[_0x22ebfe];return _0x31d930;};'use strict';var url=require(_0x32fd('0x0'));var BPromise=require(_0x32fd('0x1'));var fs=require('fs');var host=_0x32fd('0x2');module['exports']=function(_0x238e9f,_0x184ff4,_0x100d1c){return new BPromise(function(_0x3622a7,_0x361f66){var _0x48d915;if(typeof _0x238e9f!=='string'||_0x238e9f[_0x32fd('0x3')]===0x0){return _0x361f66('filepath\x20should\x20be\x20a\x20string');}if(typeof _0x184ff4!==_0x32fd('0x4')||_0x184ff4[_0x32fd('0x3')]===0x0){return _0x361f66(_0x32fd('0x5'));}if(typeof _0x100d1c!=='undefined'&&(typeof _0x100d1c!==_0x32fd('0x4')||_0x100d1c[_0x32fd('0x3')]===0x0)){return _0x361f66(_0x32fd('0x6'));}try{_0x48d915=fs[_0x32fd('0x7')](_0x238e9f)[_0x32fd('0x8')](_0x32fd('0x9'));}catch(_0x301075){return _0x361f66(_0x301075);}return _0x3622a7({'method':_0x32fd('0xa'),'uri':host+'/v1/speech:recognize?key='+_0x184ff4,'body':{'config':{'encoding':_0x32fd('0xb'),'sampleRateHertz':_0x32fd('0xc'),'languageCode':_0x100d1c},'audio':{'content':_0x48d915}},'json':!![]});});};