61a3d1bbfa8095e9c78af4fa2ce6a07643b5eb59
[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 _0x1d5b=['key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','toString','base64','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','filepath\x20should\x20be\x20a\x20string','string','length'];(function(_0x5694cd,_0x2fefe4){var _0x5235d6=function(_0x4cd263){while(--_0x4cd263){_0x5694cd['push'](_0x5694cd['shift']());}};_0x5235d6(++_0x2fefe4);}(_0x1d5b,0x13c));var _0xb1d5=function(_0x5a6d69,_0x203f47){_0x5a6d69=_0x5a6d69-0x0;var _0xb2467e=_0x1d5b[_0x5a6d69];return _0xb2467e;};'use strict';var url=require(_0xb1d5('0x0'));var BPromise=require(_0xb1d5('0x1'));var fs=require('fs');var host=_0xb1d5('0x2');module['exports']=function(_0x2739cc,_0x594c25,_0x2f9c5a){return new BPromise(function(_0x1a673c,_0xa12a1e){var _0x3ee65c;if(typeof _0x2739cc!=='string'||_0x2739cc['length']===0x0){return _0xa12a1e(_0xb1d5('0x3'));}if(typeof _0x594c25!==_0xb1d5('0x4')||_0x594c25[_0xb1d5('0x5')]===0x0){return _0xa12a1e(_0xb1d5('0x6'));}if(typeof _0x2f9c5a!==_0xb1d5('0x7')&&(typeof _0x2f9c5a!==_0xb1d5('0x4')||_0x2f9c5a[_0xb1d5('0x5')]===0x0)){return _0xa12a1e(_0xb1d5('0x8'));}try{_0x3ee65c=fs['readFileSync'](_0x2739cc)[_0xb1d5('0x9')](_0xb1d5('0xa'));}catch(_0x56fc2d){return _0xa12a1e(_0x56fc2d);}return _0x1a673c({'method':'POST','uri':host+_0xb1d5('0xb')+_0x594c25,'body':{'config':{'encoding':_0xb1d5('0xc'),'sampleRateHertz':_0xb1d5('0xd'),'languageCode':_0x2f9c5a},'audio':{'content':_0x3ee65c}},'json':!![]});});};