6113c363b2848fbc46b7f87629e81dbdc9de4890
[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 _0x2bd8=['filepath\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','readFileSync','base64','POST','/v1/speech:recognize?key=','LINEAR16','url','bluebird','https://speech.googleapis.com','exports','string','length'];(function(_0x31132e,_0x45d964){var _0x41dea6=function(_0x2c5e43){while(--_0x2c5e43){_0x31132e['push'](_0x31132e['shift']());}};_0x41dea6(++_0x45d964);}(_0x2bd8,0x1ba));var _0x82bd=function(_0x4bb409,_0x241cc4){_0x4bb409=_0x4bb409-0x0;var _0x2ef7d4=_0x2bd8[_0x4bb409];return _0x2ef7d4;};'use strict';var url=require(_0x82bd('0x0'));var BPromise=require(_0x82bd('0x1'));var fs=require('fs');var host=_0x82bd('0x2');module[_0x82bd('0x3')]=function(_0x3f8d99,_0x3f3c13,_0x1c9538){return new BPromise(function(_0x379bb1,_0x3bf48b){var _0x3cecad;if(typeof _0x3f8d99!==_0x82bd('0x4')||_0x3f8d99[_0x82bd('0x5')]===0x0){return _0x3bf48b(_0x82bd('0x6'));}if(typeof _0x3f3c13!==_0x82bd('0x4')||_0x3f3c13['length']===0x0){return _0x3bf48b('key\x20should\x20be\x20a\x20string');}if(typeof _0x1c9538!==_0x82bd('0x7')&&(typeof _0x1c9538!=='string'||_0x1c9538[_0x82bd('0x5')]===0x0)){return _0x3bf48b(_0x82bd('0x8'));}try{_0x3cecad=fs[_0x82bd('0x9')](_0x3f8d99)['toString'](_0x82bd('0xa'));}catch(_0x1a2cbb){return _0x3bf48b(_0x1a2cbb);}return _0x379bb1({'method':_0x82bd('0xb'),'uri':host+_0x82bd('0xc')+_0x3f3c13,'body':{'config':{'encoding':_0x82bd('0xd'),'sampleRateHertz':'8000','languageCode':_0x1c9538},'audio':{'content':_0x3cecad}},'json':!![]});});};