Built motion from commit ce03bc3d.|2.5.39
[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 _0xd52d=['readFileSync','toString','base64','POST','/v1/speech:recognize?key=','LINEAR16','8000','bluebird','https://speech.googleapis.com','string','length','filepath\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string'];(function(_0x488c74,_0x54a056){var _0x284625=function(_0x1a46cb){while(--_0x1a46cb){_0x488c74['push'](_0x488c74['shift']());}};_0x284625(++_0x54a056);}(_0xd52d,0x1c7));var _0xdd52=function(_0x3ff454,_0x463732){_0x3ff454=_0x3ff454-0x0;var _0x5cbf95=_0xd52d[_0x3ff454];return _0x5cbf95;};'use strict';var url=require('url');var BPromise=require(_0xdd52('0x0'));var fs=require('fs');var host=_0xdd52('0x1');module['exports']=function(_0x3bed6e,_0x52e3a8,_0x593052){return new BPromise(function(_0x1dfed5,_0x211062){var _0x30fb04;if(typeof _0x3bed6e!==_0xdd52('0x2')||_0x3bed6e[_0xdd52('0x3')]===0x0){return _0x211062(_0xdd52('0x4'));}if(typeof _0x52e3a8!==_0xdd52('0x2')||_0x52e3a8[_0xdd52('0x3')]===0x0){return _0x211062('key\x20should\x20be\x20a\x20string');}if(typeof _0x593052!==_0xdd52('0x5')&&(typeof _0x593052!==_0xdd52('0x2')||_0x593052[_0xdd52('0x3')]===0x0)){return _0x211062(_0xdd52('0x6'));}try{_0x30fb04=fs[_0xdd52('0x7')](_0x3bed6e)[_0xdd52('0x8')](_0xdd52('0x9'));}catch(_0x3e41e1){return _0x211062(_0x3e41e1);}return _0x1dfed5({'method':_0xdd52('0xa'),'uri':host+_0xdd52('0xb')+_0x52e3a8,'body':{'config':{'encoding':_0xdd52('0xc'),'sampleRateHertz':_0xdd52('0xd'),'languageCode':_0x593052},'audio':{'content':_0x30fb04}},'json':!![]});});};