d957024d03845e3e9f49706c96443c4aefbebb41
[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 _0x8f37=['base64','POST','/v1/speech:recognize?key=','8000','url','bluebird','https://speech.googleapis.com','length','string','undefined','lang\x20should\x20be\x20a\x20string','toString'];(function(_0x2847d0,_0x10a787){var _0x1cc209=function(_0x3863ff){while(--_0x3863ff){_0x2847d0['push'](_0x2847d0['shift']());}};_0x1cc209(++_0x10a787);}(_0x8f37,0x190));var _0x78f3=function(_0x19afbb,_0x52fdc7){_0x19afbb=_0x19afbb-0x0;var _0x4855c3=_0x8f37[_0x19afbb];return _0x4855c3;};'use strict';var url=require(_0x78f3('0x0'));var BPromise=require(_0x78f3('0x1'));var fs=require('fs');var host=_0x78f3('0x2');module['exports']=function(_0x542bc0,_0x2a7d93,_0x3c1fa6){return new BPromise(function(_0x3b0667,_0x539794){var _0x1d59a5;if(typeof _0x542bc0!=='string'||_0x542bc0[_0x78f3('0x3')]===0x0){return _0x539794('filepath\x20should\x20be\x20a\x20string');}if(typeof _0x2a7d93!==_0x78f3('0x4')||_0x2a7d93[_0x78f3('0x3')]===0x0){return _0x539794('key\x20should\x20be\x20a\x20string');}if(typeof _0x3c1fa6!==_0x78f3('0x5')&&(typeof _0x3c1fa6!=='string'||_0x3c1fa6[_0x78f3('0x3')]===0x0)){return _0x539794(_0x78f3('0x6'));}try{_0x1d59a5=fs['readFileSync'](_0x542bc0)[_0x78f3('0x7')](_0x78f3('0x8'));}catch(_0x268525){return _0x539794(_0x268525);}return _0x3b0667({'method':_0x78f3('0x9'),'uri':host+_0x78f3('0xa')+_0x2a7d93,'body':{'config':{'encoding':'LINEAR16','sampleRateHertz':_0x78f3('0xb'),'languageCode':_0x3c1fa6},'audio':{'content':_0x1d59a5}},'json':!![]});});};