be0e8e9d864e04b8b1a5bad76eb631bc50ff0bad
[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 _0x2e35=['length','filepath\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','readFileSync','base64','/v1/speech:recognize?key=','8000','url','bluebird','https://speech.googleapis.com','string'];(function(_0x57b59b,_0xc73d34){var _0x487368=function(_0x29e398){while(--_0x29e398){_0x57b59b['push'](_0x57b59b['shift']());}};_0x487368(++_0xc73d34);}(_0x2e35,0x1d0));var _0x52e3=function(_0x4e76be,_0x2f2407){_0x4e76be=_0x4e76be-0x0;var _0x50cb51=_0x2e35[_0x4e76be];return _0x50cb51;};'use strict';var url=require(_0x52e3('0x0'));var BPromise=require(_0x52e3('0x1'));var fs=require('fs');var host=_0x52e3('0x2');module['exports']=function(_0x145ad0,_0xcbe6c5,_0x16d807){return new BPromise(function(_0x3dc244,_0x4ccab4){var _0x158226;if(typeof _0x145ad0!==_0x52e3('0x3')||_0x145ad0[_0x52e3('0x4')]===0x0){return _0x4ccab4(_0x52e3('0x5'));}if(typeof _0xcbe6c5!=='string'||_0xcbe6c5['length']===0x0){return _0x4ccab4('key\x20should\x20be\x20a\x20string');}if(typeof _0x16d807!==_0x52e3('0x6')&&(typeof _0x16d807!=='string'||_0x16d807['length']===0x0)){return _0x4ccab4(_0x52e3('0x7'));}try{_0x158226=fs[_0x52e3('0x8')](_0x145ad0)['toString'](_0x52e3('0x9'));}catch(_0x1153c4){return _0x4ccab4(_0x1153c4);}return _0x3dc244({'method':'POST','uri':host+_0x52e3('0xa')+_0xcbe6c5,'body':{'config':{'encoding':'LINEAR16','sampleRateHertz':_0x52e3('0xb'),'languageCode':_0x16d807},'audio':{'content':_0x158226}},'json':!![]});});};