Built motion from commit (unavailable).|2.6.0
[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 _0x2e58=['filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','lang\x20should\x20be\x20a\x20string','readFileSync','toString','POST','LINEAR16','8000','url','https://speech.googleapis.com','exports','string','length'];(function(_0x4c3f39,_0x394c52){var _0x46672e=function(_0x1fabd9){while(--_0x1fabd9){_0x4c3f39['push'](_0x4c3f39['shift']());}};_0x46672e(++_0x394c52);}(_0x2e58,0x10c));var _0x82e5=function(_0x4efa28,_0x4e1805){_0x4efa28=_0x4efa28-0x0;var _0x599196=_0x2e58[_0x4efa28];return _0x599196;};'use strict';var url=require(_0x82e5('0x0'));var BPromise=require('bluebird');var fs=require('fs');var host=_0x82e5('0x1');module[_0x82e5('0x2')]=function(_0x35473b,_0x52ef71,_0x264562){return new BPromise(function(_0x367fdb,_0x116986){var _0x5e1210;if(typeof _0x35473b!==_0x82e5('0x3')||_0x35473b[_0x82e5('0x4')]===0x0){return _0x116986(_0x82e5('0x5'));}if(typeof _0x52ef71!==_0x82e5('0x3')||_0x52ef71[_0x82e5('0x4')]===0x0){return _0x116986(_0x82e5('0x6'));}if(typeof _0x264562!=='undefined'&&(typeof _0x264562!==_0x82e5('0x3')||_0x264562[_0x82e5('0x4')]===0x0)){return _0x116986(_0x82e5('0x7'));}try{_0x5e1210=fs[_0x82e5('0x8')](_0x35473b)[_0x82e5('0x9')]('base64');}catch(_0x904af0){return _0x116986(_0x904af0);}return _0x367fdb({'method':_0x82e5('0xa'),'uri':host+'/v1/speech:recognize?key='+_0x52ef71,'body':{'config':{'encoding':_0x82e5('0xb'),'sampleRateHertz':_0x82e5('0xc'),'languageCode':_0x264562},'audio':{'content':_0x5e1210}},'json':!![]});});};