Built motion from commit 746c7d2a.|2.5.35
[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 _0x98d3=['filepath\x20should\x20be\x20a\x20string','string','key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','toString','base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','exports','length'];(function(_0x3650eb,_0x1a6e22){var _0x425c8a=function(_0x43e9bb){while(--_0x43e9bb){_0x3650eb['push'](_0x3650eb['shift']());}};_0x425c8a(++_0x1a6e22);}(_0x98d3,0x173));var _0x398d=function(_0x3d2486,_0x178ad0){_0x3d2486=_0x3d2486-0x0;var _0x2cb79b=_0x98d3[_0x3d2486];return _0x2cb79b;};'use strict';var url=require(_0x398d('0x0'));var BPromise=require(_0x398d('0x1'));var fs=require('fs');var host='https://speech.googleapis.com';module[_0x398d('0x2')]=function(_0x4f5ff0,_0x18da44,_0x48fcf0){return new BPromise(function(_0x465d4a,_0x41f57c){var _0x4f7a58;if(typeof _0x4f5ff0!=='string'||_0x4f5ff0[_0x398d('0x3')]===0x0){return _0x41f57c(_0x398d('0x4'));}if(typeof _0x18da44!==_0x398d('0x5')||_0x18da44['length']===0x0){return _0x41f57c(_0x398d('0x6'));}if(typeof _0x48fcf0!==_0x398d('0x7')&&(typeof _0x48fcf0!==_0x398d('0x5')||_0x48fcf0[_0x398d('0x3')]===0x0)){return _0x41f57c(_0x398d('0x8'));}try{_0x4f7a58=fs['readFileSync'](_0x4f5ff0)[_0x398d('0x9')](_0x398d('0xa'));}catch(_0x45d5e3){return _0x41f57c(_0x45d5e3);}return _0x465d4a({'method':_0x398d('0xb'),'uri':host+_0x398d('0xc')+_0x18da44,'body':{'config':{'encoding':_0x398d('0xd'),'sampleRateHertz':_0x398d('0xe'),'languageCode':_0x48fcf0},'audio':{'content':_0x4f7a58}},'json':!![]});});};