005c86ef6cd6ad5af7aa08f5104c9f6db71af189
[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 _0xb2b5=['8000','string','length','lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','POST','LINEAR16'];(function(_0x277107,_0x3420dc){var _0x1da046=function(_0x47122d){while(--_0x47122d){_0x277107['push'](_0x277107['shift']());}};_0x1da046(++_0x3420dc);}(_0xb2b5,0xa3));var _0x5b2b=function(_0x199572,_0x33e667){_0x199572=_0x199572-0x0;var _0x13cfa3=_0xb2b5[_0x199572];return _0x13cfa3;};'use strict';var url=require('url');var BPromise=require('bluebird');var fs=require('fs');var host='https://speech.googleapis.com';module['exports']=function(_0x4746e7,_0x1431f3,_0x518fe7){return new BPromise(function(_0x4eee87,_0x31784d){var _0x11fae1;if(typeof _0x4746e7!==_0x5b2b('0x0')||_0x4746e7[_0x5b2b('0x1')]===0x0){return _0x31784d('filepath\x20should\x20be\x20a\x20string');}if(typeof _0x1431f3!==_0x5b2b('0x0')||_0x1431f3[_0x5b2b('0x1')]===0x0){return _0x31784d('key\x20should\x20be\x20a\x20string');}if(typeof _0x518fe7!=='undefined'&&(typeof _0x518fe7!==_0x5b2b('0x0')||_0x518fe7[_0x5b2b('0x1')]===0x0)){return _0x31784d(_0x5b2b('0x2'));}try{_0x11fae1=fs[_0x5b2b('0x3')](_0x4746e7)[_0x5b2b('0x4')](_0x5b2b('0x5'));}catch(_0x15425f){return _0x31784d(_0x15425f);}return _0x4eee87({'method':_0x5b2b('0x6'),'uri':host+'/v1/speech:recognize?key='+_0x1431f3,'body':{'config':{'encoding':_0x5b2b('0x7'),'sampleRateHertz':_0x5b2b('0x8'),'languageCode':_0x518fe7},'audio':{'content':_0x11fae1}},'json':!![]});});};