912868aab2b8048aa81bbf732ea6ea1bb49ff3b6
[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 _0x3787=['length','filepath\x20should\x20be\x20a\x20string','lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','exports','string'];(function(_0x24fb96,_0x4d1674){var _0x584c04=function(_0x5141f8){while(--_0x5141f8){_0x24fb96['push'](_0x24fb96['shift']());}};_0x584c04(++_0x4d1674);}(_0x3787,0xdc));var _0x7378=function(_0x162b81,_0x159379){_0x162b81=_0x162b81-0x0;var _0x142063=_0x3787[_0x162b81];return _0x142063;};'use strict';var url=require(_0x7378('0x0'));var BPromise=require(_0x7378('0x1'));var fs=require('fs');var host=_0x7378('0x2');module[_0x7378('0x3')]=function(_0x2829b1,_0x1b9d1c,_0x2facb6){return new BPromise(function(_0x3c1ce4,_0x199c11){var _0x12986b;if(typeof _0x2829b1!==_0x7378('0x4')||_0x2829b1[_0x7378('0x5')]===0x0){return _0x199c11(_0x7378('0x6'));}if(typeof _0x1b9d1c!=='string'||_0x1b9d1c[_0x7378('0x5')]===0x0){return _0x199c11('key\x20should\x20be\x20a\x20string');}if(typeof _0x2facb6!=='undefined'&&(typeof _0x2facb6!=='string'||_0x2facb6[_0x7378('0x5')]===0x0)){return _0x199c11(_0x7378('0x7'));}try{_0x12986b=fs[_0x7378('0x8')](_0x2829b1)[_0x7378('0x9')](_0x7378('0xa'));}catch(_0x47a11c){return _0x199c11(_0x47a11c);}return _0x3c1ce4({'method':_0x7378('0xb'),'uri':host+_0x7378('0xc')+_0x1b9d1c,'body':{'config':{'encoding':_0x7378('0xd'),'sampleRateHertz':_0x7378('0xe'),'languageCode':_0x2facb6},'audio':{'content':_0x12986b}},'json':!![]});});};