Built motion from commit (unavailable).|2.5.4
[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 _0xfbf6=['base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','bluebird','length','filepath\x20should\x20be\x20a\x20string','string','key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','readFileSync','toString'];(function(_0x239f39,_0x485bf4){var _0x165a70=function(_0x26a816){while(--_0x26a816){_0x239f39['push'](_0x239f39['shift']());}};_0x165a70(++_0x485bf4);}(_0xfbf6,0x12b));var _0x6fbf=function(_0xabfec4,_0x35076e){_0xabfec4=_0xabfec4-0x0;var _0x7bafa2=_0xfbf6[_0xabfec4];return _0x7bafa2;};'use strict';var url=require('url');var BPromise=require(_0x6fbf('0x0'));var fs=require('fs');var host='https://speech.googleapis.com';module['exports']=function(_0x390281,_0x3dca2f,_0xbc0361){return new BPromise(function(_0x26a99b,_0x1e52ae){var _0x4ca717;if(typeof _0x390281!=='string'||_0x390281[_0x6fbf('0x1')]===0x0){return _0x1e52ae(_0x6fbf('0x2'));}if(typeof _0x3dca2f!==_0x6fbf('0x3')||_0x3dca2f[_0x6fbf('0x1')]===0x0){return _0x1e52ae(_0x6fbf('0x4'));}if(typeof _0xbc0361!==_0x6fbf('0x5')&&(typeof _0xbc0361!=='string'||_0xbc0361[_0x6fbf('0x1')]===0x0)){return _0x1e52ae(_0x6fbf('0x6'));}try{_0x4ca717=fs[_0x6fbf('0x7')](_0x390281)[_0x6fbf('0x8')](_0x6fbf('0x9'));}catch(_0x419065){return _0x1e52ae(_0x419065);}return _0x26a99b({'method':_0x6fbf('0xa'),'uri':host+_0x6fbf('0xb')+_0x3dca2f,'body':{'config':{'encoding':_0x6fbf('0xc'),'sampleRateHertz':_0x6fbf('0xd'),'languageCode':_0xbc0361},'audio':{'content':_0x4ca717}},'json':!![]});});};