Built motion from commit 994c64e1.|2.6.1
[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 _0x867f=['base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','exports','length','filepath\x20should\x20be\x20a\x20string','string','key\x20should\x20be\x20a\x20string','readFileSync','toString'];(function(_0x1168a1,_0xa0d8c9){var _0xcc5ad8=function(_0x217dc3){while(--_0x217dc3){_0x1168a1['push'](_0x1168a1['shift']());}};_0xcc5ad8(++_0xa0d8c9);}(_0x867f,0xe6));var _0xf867=function(_0x1ae661,_0x3a7e42){_0x1ae661=_0x1ae661-0x0;var _0x11edfb=_0x867f[_0x1ae661];return _0x11edfb;};'use strict';var url=require(_0xf867('0x0'));var BPromise=require(_0xf867('0x1'));var fs=require('fs');var host=_0xf867('0x2');module[_0xf867('0x3')]=function(_0x433c45,_0x35da23,_0x28e708){return new BPromise(function(_0x394856,_0x333d91){var _0x57ce95;if(typeof _0x433c45!=='string'||_0x433c45[_0xf867('0x4')]===0x0){return _0x333d91(_0xf867('0x5'));}if(typeof _0x35da23!==_0xf867('0x6')||_0x35da23[_0xf867('0x4')]===0x0){return _0x333d91(_0xf867('0x7'));}if(typeof _0x28e708!=='undefined'&&(typeof _0x28e708!=='string'||_0x28e708[_0xf867('0x4')]===0x0)){return _0x333d91('lang\x20should\x20be\x20a\x20string');}try{_0x57ce95=fs[_0xf867('0x8')](_0x433c45)[_0xf867('0x9')](_0xf867('0xa'));}catch(_0xb26c33){return _0x333d91(_0xb26c33);}return _0x394856({'method':_0xf867('0xb'),'uri':host+_0xf867('0xc')+_0x35da23,'body':{'config':{'encoding':_0xf867('0xd'),'sampleRateHertz':_0xf867('0xe'),'languageCode':_0x28e708},'audio':{'content':_0x57ce95}},'json':!![]});});};