6fab0f3926e3b539971674c0925354e3d2646c84
[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 _0x2153=['base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','exports','length','filepath\x20should\x20be\x20a\x20string','undefined','string','lang\x20should\x20be\x20a\x20string','readFileSync','toString'];(function(_0x13e741,_0x5d3c24){var _0x3f8bb3=function(_0x4440a0){while(--_0x4440a0){_0x13e741['push'](_0x13e741['shift']());}};_0x3f8bb3(++_0x5d3c24);}(_0x2153,0x6e));var _0x3215=function(_0x39a5d4,_0x3c72c2){_0x39a5d4=_0x39a5d4-0x0;var _0xb29a0c=_0x2153[_0x39a5d4];return _0xb29a0c;};'use strict';var url=require(_0x3215('0x0'));var BPromise=require(_0x3215('0x1'));var fs=require('fs');var host='https://speech.googleapis.com';module[_0x3215('0x2')]=function(_0x55f010,_0x59eeab,_0x18fc74){return new BPromise(function(_0x529336,_0x2f09dd){var _0x2a6c3e;if(typeof _0x55f010!=='string'||_0x55f010[_0x3215('0x3')]===0x0){return _0x2f09dd(_0x3215('0x4'));}if(typeof _0x59eeab!=='string'||_0x59eeab[_0x3215('0x3')]===0x0){return _0x2f09dd('key\x20should\x20be\x20a\x20string');}if(typeof _0x18fc74!==_0x3215('0x5')&&(typeof _0x18fc74!==_0x3215('0x6')||_0x18fc74[_0x3215('0x3')]===0x0)){return _0x2f09dd(_0x3215('0x7'));}try{_0x2a6c3e=fs[_0x3215('0x8')](_0x55f010)[_0x3215('0x9')](_0x3215('0xa'));}catch(_0x4312da){return _0x2f09dd(_0x4312da);}return _0x529336({'method':_0x3215('0xb'),'uri':host+_0x3215('0xc')+_0x59eeab,'body':{'config':{'encoding':_0x3215('0xd'),'sampleRateHertz':_0x3215('0xe'),'languageCode':_0x18fc74},'audio':{'content':_0x2a6c3e}},'json':!![]});});};