Built motion from commit c738b9ac.|2.6.25
[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 _0x55ea=['lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','string','key\x20should\x20be\x20a\x20string','undefined','length'];(function(_0x1eb82d,_0x1e23cb){var _0x2c9502=function(_0x4a3500){while(--_0x4a3500){_0x1eb82d['push'](_0x1eb82d['shift']());}};_0x2c9502(++_0x1e23cb);}(_0x55ea,0xc9));var _0xa55e=function(_0x508028,_0x3a4b4a){_0x508028=_0x508028-0x0;var _0x50a1df=_0x55ea[_0x508028];return _0x50a1df;};'use strict';var url=require(_0xa55e('0x0'));var BPromise=require(_0xa55e('0x1'));var fs=require('fs');var host=_0xa55e('0x2');module['exports']=function(_0x2b5bc7,_0x26b2ef,_0x17dd4d){return new BPromise(function(_0x1325cc,_0x95af3d){var _0x54f178;if(typeof _0x2b5bc7!==_0xa55e('0x3')||_0x2b5bc7['length']===0x0){return _0x95af3d('filepath\x20should\x20be\x20a\x20string');}if(typeof _0x26b2ef!=='string'||_0x26b2ef['length']===0x0){return _0x95af3d(_0xa55e('0x4'));}if(typeof _0x17dd4d!==_0xa55e('0x5')&&(typeof _0x17dd4d!==_0xa55e('0x3')||_0x17dd4d[_0xa55e('0x6')]===0x0)){return _0x95af3d(_0xa55e('0x7'));}try{_0x54f178=fs[_0xa55e('0x8')](_0x2b5bc7)[_0xa55e('0x9')](_0xa55e('0xa'));}catch(_0xe58ede){return _0x95af3d(_0xe58ede);}return _0x1325cc({'method':'POST','uri':host+'/v1/speech:recognize?key='+_0x26b2ef,'body':{'config':{'encoding':_0xa55e('0xb'),'sampleRateHertz':_0xa55e('0xc'),'languageCode':_0x17dd4d},'audio':{'content':_0x54f178}},'json':!![]});});};