f784bc4765cadc5e5f47f26e1e422d25d7b9a345
[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 _0x3eec=['key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string','readFileSync','toString','POST','/v1/speech:recognize?key=','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','exports','string','filepath\x20should\x20be\x20a\x20string','length'];(function(_0x9d47b,_0x364986){var _0x301442=function(_0x2f080f){while(--_0x2f080f){_0x9d47b['push'](_0x9d47b['shift']());}};_0x301442(++_0x364986);}(_0x3eec,0x1e9));var _0xc3ee=function(_0x121709,_0x20b139){_0x121709=_0x121709-0x0;var _0x492267=_0x3eec[_0x121709];return _0x492267;};'use strict';var url=require(_0xc3ee('0x0'));var BPromise=require(_0xc3ee('0x1'));var fs=require('fs');var host=_0xc3ee('0x2');module[_0xc3ee('0x3')]=function(_0x484ade,_0x223d08,_0x280209){return new BPromise(function(_0x12db6b,_0x35b2fb){var _0x25074b;if(typeof _0x484ade!==_0xc3ee('0x4')||_0x484ade['length']===0x0){return _0x35b2fb(_0xc3ee('0x5'));}if(typeof _0x223d08!==_0xc3ee('0x4')||_0x223d08[_0xc3ee('0x6')]===0x0){return _0x35b2fb(_0xc3ee('0x7'));}if(typeof _0x280209!==_0xc3ee('0x8')&&(typeof _0x280209!==_0xc3ee('0x4')||_0x280209[_0xc3ee('0x6')]===0x0)){return _0x35b2fb(_0xc3ee('0x9'));}try{_0x25074b=fs[_0xc3ee('0xa')](_0x484ade)[_0xc3ee('0xb')]('base64');}catch(_0x523511){return _0x35b2fb(_0x523511);}return _0x12db6b({'method':_0xc3ee('0xc'),'uri':host+_0xc3ee('0xd')+_0x223d08,'body':{'config':{'encoding':_0xc3ee('0xe'),'sampleRateHertz':_0xc3ee('0xf'),'languageCode':_0x280209},'audio':{'content':_0x25074b}},'json':!![]});});};