f53ddcdc39a5542936d4fcf2266165c4a4b074c0
[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 _0x0c02=['length','filepath\x20should\x20be\x20a\x20string','lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','bluebird','https://speech.googleapis.com','string'];(function(_0x1fa91a,_0x33ac8c){var _0x2e63eb=function(_0x14796d){while(--_0x14796d){_0x1fa91a['push'](_0x1fa91a['shift']());}};_0x2e63eb(++_0x33ac8c);}(_0x0c02,0x84));var _0x20c0=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x0c02[_0x3dd15e];return _0x231fd0;};'use strict';var url=require('url');var BPromise=require(_0x20c0('0x0'));var fs=require('fs');var host=_0x20c0('0x1');module['exports']=function(_0x1338cf,_0x5c8750,_0x454922){return new BPromise(function(_0x6d03d0,_0x38022e){var _0x2e9d65;if(typeof _0x1338cf!==_0x20c0('0x2')||_0x1338cf[_0x20c0('0x3')]===0x0){return _0x38022e(_0x20c0('0x4'));}if(typeof _0x5c8750!==_0x20c0('0x2')||_0x5c8750['length']===0x0){return _0x38022e('key\x20should\x20be\x20a\x20string');}if(typeof _0x454922!=='undefined'&&(typeof _0x454922!=='string'||_0x454922[_0x20c0('0x3')]===0x0)){return _0x38022e(_0x20c0('0x5'));}try{_0x2e9d65=fs[_0x20c0('0x6')](_0x1338cf)[_0x20c0('0x7')](_0x20c0('0x8'));}catch(_0xedd21d){return _0x38022e(_0xedd21d);}return _0x6d03d0({'method':'POST','uri':host+'/v1/speech:recognize?key='+_0x5c8750,'body':{'config':{'encoding':'LINEAR16','sampleRateHertz':'8000','languageCode':_0x454922},'audio':{'content':_0x2e9d65}},'json':!![]});});};