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 _0x06fd=['string','length','filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','POST','/v1/speech:recognize?key=','url','bluebird','https://speech.googleapis.com'];(function(_0x5d1a07,_0x169a8d){var _0x458ece=function(_0x9467f4){while(--_0x9467f4){_0x5d1a07['push'](_0x5d1a07['shift']());}};_0x458ece(++_0x169a8d);}(_0x06fd,0xa8));var _0xd06f=function(_0x1a0600,_0x41feef){_0x1a0600=_0x1a0600-0x0;var _0x734670=_0x06fd[_0x1a0600];return _0x734670;};'use strict';var url=require(_0xd06f('0x0'));var BPromise=require(_0xd06f('0x1'));var fs=require('fs');var host=_0xd06f('0x2');module['exports']=function(_0x399ea2,_0x435dc0,_0x15481a){return new BPromise(function(_0x41ed31,_0x57658d){var _0x89db4;if(typeof _0x399ea2!==_0xd06f('0x3')||_0x399ea2[_0xd06f('0x4')]===0x0){return _0x57658d(_0xd06f('0x5'));}if(typeof _0x435dc0!==_0xd06f('0x3')||_0x435dc0[_0xd06f('0x4')]===0x0){return _0x57658d(_0xd06f('0x6'));}if(typeof _0x15481a!=='undefined'&&(typeof _0x15481a!==_0xd06f('0x3')||_0x15481a[_0xd06f('0x4')]===0x0)){return _0x57658d('lang\x20should\x20be\x20a\x20string');}try{_0x89db4=fs['readFileSync'](_0x399ea2)['toString']('base64');}catch(_0x355721){return _0x57658d(_0x355721);}return _0x41ed31({'method':_0xd06f('0x7'),'uri':host+_0xd06f('0x8')+_0x435dc0,'body':{'config':{'encoding':'LINEAR16','sampleRateHertz':'8000','languageCode':_0x15481a},'audio':{'content':_0x89db4}},'json':!![]});});};