ebe3d75ae88dbfa13d4e2a00d06a27a498564087
[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 _0x70e0=['8000','url','bluebird','https://speech.googleapis.com','string','filepath\x20should\x20be\x20a\x20string','undefined','length','lang\x20should\x20be\x20a\x20string','readFileSync','toString','base64','/v1/speech:recognize?key=','LINEAR16'];(function(_0x836465,_0x5442ae){var _0x2150ea=function(_0x4f4bc2){while(--_0x4f4bc2){_0x836465['push'](_0x836465['shift']());}};_0x2150ea(++_0x5442ae);}(_0x70e0,0x17b));var _0x070e=function(_0x1e8c33,_0x438a1f){_0x1e8c33=_0x1e8c33-0x0;var _0x196e99=_0x70e0[_0x1e8c33];return _0x196e99;};'use strict';var url=require(_0x070e('0x0'));var BPromise=require(_0x070e('0x1'));var fs=require('fs');var host=_0x070e('0x2');module['exports']=function(_0x579b83,_0x16e651,_0xee173){return new BPromise(function(_0x277d32,_0x2593e5){var _0x5c90fc;if(typeof _0x579b83!==_0x070e('0x3')||_0x579b83['length']===0x0){return _0x2593e5(_0x070e('0x4'));}if(typeof _0x16e651!=='string'||_0x16e651['length']===0x0){return _0x2593e5('key\x20should\x20be\x20a\x20string');}if(typeof _0xee173!==_0x070e('0x5')&&(typeof _0xee173!==_0x070e('0x3')||_0xee173[_0x070e('0x6')]===0x0)){return _0x2593e5(_0x070e('0x7'));}try{_0x5c90fc=fs[_0x070e('0x8')](_0x579b83)[_0x070e('0x9')](_0x070e('0xa'));}catch(_0x4e99e6){return _0x2593e5(_0x4e99e6);}return _0x277d32({'method':'POST','uri':host+_0x070e('0xb')+_0x16e651,'body':{'config':{'encoding':_0x070e('0xc'),'sampleRateHertz':_0x070e('0xd'),'languageCode':_0xee173},'audio':{'content':_0x5c90fc}},'json':!![]});});};