Built motion from commit a61a4a20.|2.5.46
[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 _0x0506=['/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','filepath\x20should\x20be\x20a\x20string','string','length','key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','toString','POST'];(function(_0xcf581b,_0x4359dd){var _0x4f454d=function(_0x182d58){while(--_0x182d58){_0xcf581b['push'](_0xcf581b['shift']());}};_0x4f454d(++_0x4359dd);}(_0x0506,0x1d1));var _0x6050=function(_0x5d7798,_0x227be6){_0x5d7798=_0x5d7798-0x0;var _0x2a586b=_0x0506[_0x5d7798];return _0x2a586b;};'use strict';var url=require(_0x6050('0x0'));var BPromise=require(_0x6050('0x1'));var fs=require('fs');var host=_0x6050('0x2');module['exports']=function(_0x52f82b,_0x5139c7,_0x49a1ca){return new BPromise(function(_0x229b5f,_0x58e2a9){var _0x3cbb1f;if(typeof _0x52f82b!=='string'||_0x52f82b['length']===0x0){return _0x58e2a9(_0x6050('0x3'));}if(typeof _0x5139c7!==_0x6050('0x4')||_0x5139c7[_0x6050('0x5')]===0x0){return _0x58e2a9(_0x6050('0x6'));}if(typeof _0x49a1ca!==_0x6050('0x7')&&(typeof _0x49a1ca!==_0x6050('0x4')||_0x49a1ca[_0x6050('0x5')]===0x0)){return _0x58e2a9(_0x6050('0x8'));}try{_0x3cbb1f=fs['readFileSync'](_0x52f82b)[_0x6050('0x9')]('base64');}catch(_0x15ad99){return _0x58e2a9(_0x15ad99);}return _0x229b5f({'method':_0x6050('0xa'),'uri':host+_0x6050('0xb')+_0x5139c7,'body':{'config':{'encoding':_0x6050('0xc'),'sampleRateHertz':_0x6050('0xd'),'languageCode':_0x49a1ca},'audio':{'content':_0x3cbb1f}},'json':!![]});});};