e967078e58c7a0b8e0ba3fe5bb4aa53f0757d562
[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 _0xd166=['undefined','lang\x20should\x20be\x20a\x20string','readFileSync','toString','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','https://speech.googleapis.com','exports','length','filepath\x20should\x20be\x20a\x20string','string'];(function(_0x5800da,_0x2e9d7f){var _0x52224d=function(_0x4131b5){while(--_0x4131b5){_0x5800da['push'](_0x5800da['shift']());}};_0x52224d(++_0x2e9d7f);}(_0xd166,0xda));var _0x6d16=function(_0x32af99,_0x13e5c4){_0x32af99=_0x32af99-0x0;var _0x1cf2c9=_0xd166[_0x32af99];return _0x1cf2c9;};'use strict';var url=require(_0x6d16('0x0'));var BPromise=require('bluebird');var fs=require('fs');var host=_0x6d16('0x1');module[_0x6d16('0x2')]=function(_0x5e1f87,_0x2a7640,_0x893a59){return new BPromise(function(_0x50290b,_0x1319df){var _0x57b05e;if(typeof _0x5e1f87!=='string'||_0x5e1f87[_0x6d16('0x3')]===0x0){return _0x1319df(_0x6d16('0x4'));}if(typeof _0x2a7640!==_0x6d16('0x5')||_0x2a7640['length']===0x0){return _0x1319df('key\x20should\x20be\x20a\x20string');}if(typeof _0x893a59!==_0x6d16('0x6')&&(typeof _0x893a59!==_0x6d16('0x5')||_0x893a59[_0x6d16('0x3')]===0x0)){return _0x1319df(_0x6d16('0x7'));}try{_0x57b05e=fs[_0x6d16('0x8')](_0x5e1f87)[_0x6d16('0x9')]('base64');}catch(_0x45e959){return _0x1319df(_0x45e959);}return _0x50290b({'method':_0x6d16('0xa'),'uri':host+_0x6d16('0xb')+_0x2a7640,'body':{'config':{'encoding':_0x6d16('0xc'),'sampleRateHertz':_0x6d16('0xd'),'languageCode':_0x893a59},'audio':{'content':_0x57b05e}},'json':!![]});});};