Built motion from commit (unavailable).|2.3.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 _0xbf1a=['length','filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','readFileSync','toString','base64','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','string'];(function(_0x39c3cf,_0x5a49aa){var _0x381914=function(_0x31bac7){while(--_0x31bac7){_0x39c3cf['push'](_0x39c3cf['shift']());}};_0x381914(++_0x5a49aa);}(_0xbf1a,0x158));var _0xabf1=function(_0x237872,_0x3ff1d9){_0x237872=_0x237872-0x0;var _0x419817=_0xbf1a[_0x237872];return _0x419817;};'use strict';var url=require(_0xabf1('0x0'));var BPromise=require(_0xabf1('0x1'));var fs=require('fs');var host=_0xabf1('0x2');module['exports']=function(_0x26437f,_0x204611,_0x263487){return new BPromise(function(_0x47e1b6,_0x1cade1){var _0x2b29c1;if(typeof _0x26437f!==_0xabf1('0x3')||_0x26437f[_0xabf1('0x4')]===0x0){return _0x1cade1(_0xabf1('0x5'));}if(typeof _0x204611!==_0xabf1('0x3')||_0x204611[_0xabf1('0x4')]===0x0){return _0x1cade1(_0xabf1('0x6'));}if(typeof _0x263487!=='undefined'&&(typeof _0x263487!=='string'||_0x263487[_0xabf1('0x4')]===0x0)){return _0x1cade1('lang\x20should\x20be\x20a\x20string');}try{_0x2b29c1=fs[_0xabf1('0x7')](_0x26437f)[_0xabf1('0x8')](_0xabf1('0x9'));}catch(_0x11bb3d){return _0x1cade1(_0x11bb3d);}return _0x47e1b6({'method':'POST','uri':host+'/v1/speech:recognize?key='+_0x204611,'body':{'config':{'encoding':_0xabf1('0xa'),'sampleRateHertz':_0xabf1('0xb'),'languageCode':_0x263487},'audio':{'content':_0x2b29c1}},'json':!![]});});};