Built motion from commit fe909640.|2.6.8
[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 _0x35aa=['filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','bluebird','https://speech.googleapis.com','exports','string','length'];(function(_0x1b46f9,_0x56e5ed){var _0x307b16=function(_0x98dab3){while(--_0x98dab3){_0x1b46f9['push'](_0x1b46f9['shift']());}};_0x307b16(++_0x56e5ed);}(_0x35aa,0xbe));var _0xa35a=function(_0x2b8bbe,_0x37eb6a){_0x2b8bbe=_0x2b8bbe-0x0;var _0x1bb210=_0x35aa[_0x2b8bbe];return _0x1bb210;};'use strict';var url=require('url');var BPromise=require(_0xa35a('0x0'));var fs=require('fs');var host=_0xa35a('0x1');module[_0xa35a('0x2')]=function(_0x3518ac,_0x5c294c,_0x2e9bcf){return new BPromise(function(_0x4303b4,_0x24cc2){var _0x11f841;if(typeof _0x3518ac!==_0xa35a('0x3')||_0x3518ac[_0xa35a('0x4')]===0x0){return _0x24cc2(_0xa35a('0x5'));}if(typeof _0x5c294c!==_0xa35a('0x3')||_0x5c294c['length']===0x0){return _0x24cc2(_0xa35a('0x6'));}if(typeof _0x2e9bcf!=='undefined'&&(typeof _0x2e9bcf!==_0xa35a('0x3')||_0x2e9bcf[_0xa35a('0x4')]===0x0)){return _0x24cc2(_0xa35a('0x7'));}try{_0x11f841=fs[_0xa35a('0x8')](_0x3518ac)[_0xa35a('0x9')](_0xa35a('0xa'));}catch(_0x48f7f4){return _0x24cc2(_0x48f7f4);}return _0x4303b4({'method':_0xa35a('0xb'),'uri':host+_0xa35a('0xc')+_0x5c294c,'body':{'config':{'encoding':_0xa35a('0xd'),'sampleRateHertz':_0xa35a('0xe'),'languageCode':_0x2e9bcf},'audio':{'content':_0x11f841}},'json':!![]});});};