Built motion from commit (unavailable).|2.2.3
[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 _0x7aed=['readFileSync','LINEAR16','8000','url','bluebird','https://speech.googleapis.com','string','length','key\x20should\x20be\x20a\x20string','undefined','lang\x20should\x20be\x20a\x20string'];(function(_0x2c7618,_0x26be9c){var _0x5ce3f0=function(_0x1837b3){while(--_0x1837b3){_0x2c7618['push'](_0x2c7618['shift']());}};_0x5ce3f0(++_0x26be9c);}(_0x7aed,0xc9));var _0xd7ae=function(_0x46c0e2,_0x431822){_0x46c0e2=_0x46c0e2-0x0;var _0x5ab592=_0x7aed[_0x46c0e2];return _0x5ab592;};'use strict';var url=require(_0xd7ae('0x0'));var BPromise=require(_0xd7ae('0x1'));var fs=require('fs');var host=_0xd7ae('0x2');module['exports']=function(_0x424d2d,_0x5b2255,_0x246335){return new BPromise(function(_0x41d19c,_0xc0b866){var _0x186870;if(typeof _0x424d2d!==_0xd7ae('0x3')||_0x424d2d['length']===0x0){return _0xc0b866('filepath\x20should\x20be\x20a\x20string');}if(typeof _0x5b2255!==_0xd7ae('0x3')||_0x5b2255[_0xd7ae('0x4')]===0x0){return _0xc0b866(_0xd7ae('0x5'));}if(typeof _0x246335!==_0xd7ae('0x6')&&(typeof _0x246335!=='string'||_0x246335[_0xd7ae('0x4')]===0x0)){return _0xc0b866(_0xd7ae('0x7'));}try{_0x186870=fs[_0xd7ae('0x8')](_0x424d2d)['toString']('base64');}catch(_0x29240e){return _0xc0b866(_0x29240e);}return _0x41d19c({'method':'POST','uri':host+'/v1/speech:recognize?key='+_0x5b2255,'body':{'config':{'encoding':_0xd7ae('0x9'),'sampleRateHertz':_0xd7ae('0xa'),'languageCode':_0x246335},'audio':{'content':_0x186870}},'json':!![]});});};