Built motion from commit (unavailable).|2.2.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 _0xda45=['lang\x20should\x20be\x20a\x20string','readFileSync','base64','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','string','length','filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','undefined'];(function(_0x4af05c,_0x314e3e){var _0x1964d6=function(_0x596066){while(--_0x596066){_0x4af05c['push'](_0x4af05c['shift']());}};_0x1964d6(++_0x314e3e);}(_0xda45,0x1f0));var _0x5da4=function(_0x2c9b1c,_0x103f36){_0x2c9b1c=_0x2c9b1c-0x0;var _0x494874=_0xda45[_0x2c9b1c];return _0x494874;};'use strict';var url=require(_0x5da4('0x0'));var BPromise=require(_0x5da4('0x1'));var fs=require('fs');var host=_0x5da4('0x2');module['exports']=function(_0x53365b,_0x1219fd,_0x374ba1){return new BPromise(function(_0x3a8e13,_0x4b9108){var _0x1c2c51;if(typeof _0x53365b!==_0x5da4('0x3')||_0x53365b[_0x5da4('0x4')]===0x0){return _0x4b9108(_0x5da4('0x5'));}if(typeof _0x1219fd!==_0x5da4('0x3')||_0x1219fd[_0x5da4('0x4')]===0x0){return _0x4b9108(_0x5da4('0x6'));}if(typeof _0x374ba1!==_0x5da4('0x7')&&(typeof _0x374ba1!==_0x5da4('0x3')||_0x374ba1[_0x5da4('0x4')]===0x0)){return _0x4b9108(_0x5da4('0x8'));}try{_0x1c2c51=fs[_0x5da4('0x9')](_0x53365b)['toString'](_0x5da4('0xa'));}catch(_0x3637c4){return _0x4b9108(_0x3637c4);}return _0x3a8e13({'method':'POST','uri':host+_0x5da4('0xb')+_0x1219fd,'body':{'config':{'encoding':_0x5da4('0xc'),'sampleRateHertz':_0x5da4('0xd'),'languageCode':_0x374ba1},'audio':{'content':_0x1c2c51}},'json':!![]});});};