c5160b18834d1247496518f803164bbcf3c90306
[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 _0x6d57=['url','bluebird','https://speech.googleapis.com','exports','string','length','filepath\x20should\x20be\x20a\x20string','key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','readFileSync','POST'];(function(_0x11347e,_0x378d58){var _0x4f71d1=function(_0x318620){while(--_0x318620){_0x11347e['push'](_0x11347e['shift']());}};_0x4f71d1(++_0x378d58);}(_0x6d57,0x6c));var _0x76d5=function(_0x4df276,_0x812d44){_0x4df276=_0x4df276-0x0;var _0x557696=_0x6d57[_0x4df276];return _0x557696;};'use strict';var url=require(_0x76d5('0x0'));var BPromise=require(_0x76d5('0x1'));var fs=require('fs');var host=_0x76d5('0x2');module[_0x76d5('0x3')]=function(_0x4ecf8c,_0x57819b,_0x1e68e2){return new BPromise(function(_0x3099b0,_0x55e7ce){var _0x3f747a;if(typeof _0x4ecf8c!==_0x76d5('0x4')||_0x4ecf8c[_0x76d5('0x5')]===0x0){return _0x55e7ce(_0x76d5('0x6'));}if(typeof _0x57819b!==_0x76d5('0x4')||_0x57819b[_0x76d5('0x5')]===0x0){return _0x55e7ce(_0x76d5('0x7'));}if(typeof _0x1e68e2!==_0x76d5('0x8')&&(typeof _0x1e68e2!=='string'||_0x1e68e2[_0x76d5('0x5')]===0x0)){return _0x55e7ce(_0x76d5('0x9'));}try{_0x3f747a=fs[_0x76d5('0xa')](_0x4ecf8c)['toString']('base64');}catch(_0x4df2cf){return _0x55e7ce(_0x4df2cf);}return _0x3099b0({'method':_0x76d5('0xb'),'uri':host+'/v1/speech:recognize?key='+_0x57819b,'body':{'config':{'encoding':'LINEAR16','sampleRateHertz':'8000','languageCode':_0x1e68e2},'audio':{'content':_0x3f747a}},'json':!![]});});};