-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
The parameters next to the url are optional protocols https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
Hi @DemianD ! Thanks for opening this PR. It does appear to resolve the issue for Bing Speech Service use, but unfortunately it breaks usage with Custom Speech Service, because it needs the authorisation headers when this library is run within NodeJS environments. We'll need some additional logic in order to selectively include these arguments depending on which speech API endpoint you're using. Alternatively, we can also filter by whether or not we are running this in a browser environment. Thoughts? Thanks again 🙏 |
dist/BingSpeechServiceNode.js
Outdated
@@ -19,7 +19,7 @@ module.exports = function (dependencies) { | |||
|
|||
|
|||
var debug = void 0; | |||
var globalDebugMode = process && process.env && process.env.DEBUG; | |||
var globalDebugMode = process && process.env && 'false'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be inlined. TODO: exclude
e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0===t.TYPED_ARRAY_SUPPORT?function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}():t.TYPED_ARRAY_SUPPORT,e.kMaxLength=o(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,n){return a(null,t,e,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return c(null,t,e,n)},u.allocUnsafe=function(t){return h(null,t)},u.allocUnsafeSlow=function(t){return h(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Q(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!et(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=u.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},u.byteLength=v,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(0!=t%2)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(0!=t%4)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(0!=t%8)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?k(this,0,t):w.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,n,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),0>e||n>t.length||0>r||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,s=n-e,a=Q(o,s),f=this.slice(r,i),c=t.slice(e,n),h=0;h<a;++h)if(f[h]!==c[h]){o=f[h],s=c[h];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return b(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return b(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),0<t.length&&(0>n||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return A(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return T(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return S(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var nt=4096;u.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,0>t?0>(t+=n)&&(t=0):t>n&&(t=n),0>e?0>(e+=n)&&(e=0):e>n&&(e=n),e<t&&(e=t);var r;if(u.TYPED_ARRAY_SUPPORT)r=this.subarray(t,e),r.__proto__=u.prototype;else{var i=e-t;r=new u(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||Y(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||Y(t,e,this.length);for(var r=this[t+--e],i=1;0<e&&(i*=256);)r+=this[t+--e]*i;return r},u.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||Y(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=r(2,8*e)),i},u.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||Y(t,e,this.length);for(var i=e,o=1,s=this[t+--i];0<i&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=r(2,8*e)),s},u.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),tt.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),tt.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),tt.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),tt.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){D(this,t,e,n,r(2,8*n)-1,0)}var o=1,s=0;for(this[e]=255&t;++s<n&&(o*=256);)this[e+s]=255&t/o;return e+n},u.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e|=0,n|=0,!i){D(this,t,e,n,r(2,8*n)-1,0)}var o=n-1,s=1;for(this[e+o]=255&t;0<=--o&&(s*=256);)this[e+o]=255&t/s;return e+n},u.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=i(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):C(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):C(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e|=0,!i){var o=r(2,8*n-1);D(this,t,e,n,o-1,-o)}var s=0,u=1,a=0;for(this[e]=255&t;++s<n&&(u*=256);)0>t&&0==a&&0!==this[e+s-1]&&(a=1),this[e+s]=255&(t/u>>0)-a;return e+n},u.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e|=0,!i){var o=r(2,8*n-1);D(this,t,e,n,o-1,-o)}var s=n-1,u=1,a=0;for(this[e+s]=255&t;0<=--s&&(u*=256);)0>t&&0==a&&0!==this[e+s+1]&&(a=1),this[e+s]=255&(t/u>>0)-a;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=i(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):C(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):C(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,n){return N(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return N(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return F(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return F(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),0<r&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;0<=i;--i)t[i+e]=this[i+n];else if(1e3>o||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);256>i&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(0>e||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var o;if("number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=u.isBuffer(t)?t:W(new u(t,r).toString()),a=s.length;for(o=0;o<n-e;++o)this[o+e]=s[o%a]}return this};var rt=/[^+\/0-9A-Za-z-_]/g}).call(e,n(5))},function(t){var e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,e){"use strict";function n(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function r(t){return o[63&t>>18]+o[63&t>>12]+o[63&t>>6]+o[63&t]}function i(t,e,n){for(var i,o=[],s=e;s<n;s+=3)i=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(r(i));return o.join("")}e.byteLength=function(t){return 3*t.length/4-n(t)},e.toByteArray=function(t){var e,r,i,o,a,f=t.length;o=n(t),a=new u(3*f/4-o),r=0<o?f-4:f;var c=0;for(e=0;e<r;e+=4)i=s[t.charCodeAt(e)]<<18|s[t.charCodeAt(e+1)]<<12|s[t.charCodeAt(e+2)]<<6|s[t.charCodeAt(e+3)],a[c++]=255&i>>16,a[c++]=255&i>>8,a[c++]=255&i;return 2===o?(i=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,a[c++]=255&i):1===o&&(i=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,a[c++]=255&i>>8,a[c++]=255&i),a},e.fromByteArray=function(t){for(var e,n=t.length,r=n%3,s="",u=[],a=16383,f=0,c=n-r;f<c;f+=a)u.push(i(t,f,f+a>c?c:f+a));return 1==r?(e=t[n-1],s+=o[e>>2],s+=o[63&e<<4],s+="=="):2==r&&(e=(t[n-2]<<8)+t[n-1],s+=o[e>>10],s+=o[63&e>>4],s+=o[63&e<<2],s+="="),u.push(s),u.join("")};for(var o=[],s=[],u="undefined"==typeof Uint8Array?Array:Uint8Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,c=a.length;f<c;++f)o[f]=a[f],s[a.charCodeAt(f)]=f;s[45]=62,s[95]=63},function(t,e){var n=Math.pow;e.read=function(t,e,r,i,o){var s,u,a=8*o-i-1,f=(1<<a)-1,c=f>>1,h=-7,l=r?o-1:0,p=r?-1:1,g=t[e+l];for(l+=p,s=g&(1<<-h)-1,g>>=-h,h+=a;0<h;s=256*s+t[e+l],l+=p,h-=8);for(u=s&(1<<-h)-1,s>>=-h,h+=i;0<h;u=256*u+t[e+l],l+=p,h-=8);if(0===s)s=1-c;else{if(s===f)return u?NaN:1/0*(g?-1:1);u+=n(2,i),s-=c}return(g?-1:1)*u*n(2,s-i)},e.write=function(t,e,r,i,o,s){var u,a,f,c=8*s-o-1,h=(1<<c)-1,l=h>>1,p=23===o?5.960464477539062e-8:0,g=i?0:s-1,y=i?1:-1,d=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,u=h):(u=Math.floor(Math.log(e)/Math.LN2),1>e*(f=n(2,-u))&&(u--,f*=2),e+=1<=u+l?p/f:p*n(2,1-l),2<=e*f&&(u++,f/=2),u+l>=h?(a=0,u=h):1<=u+l?(a=(e*f-1)*n(2,o),u+=l):(a=e*n(2,l-1)*n(2,o),u=0));8<=o;t[r+g]=255&a,g+=y,a/=256,o-=8);for(u=u<<o|a,c+=o;0<c;t[r+g]=255&u,g+=y,u/=256,c-=8);t[r+g-y]|=128*d}},function(t){var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},function(t,e){var n=Number.MAX_VALUE;e.endianness=function(){return"LE"},e.hostname=function(){return"undefined"==typeof location?"":location.hostname},e.loadavg=function(){return[]},e.uptime=function(){return 0},e.freemem=function(){return n},e.totalmem=function(){return n},e.cpus=function(){return[]},e.type=function(){return"Browser"},e.release=function(){return"undefined"==typeof navigator?"":navigator.appVersion},e.networkInterfaces=e.getNetworkInterfaces=function(){return{}},e.arch=function(){return"javascript"},e.platform=function(){return"browser"},e.tmpdir=e.tmpDir=function(){return"/tmp"},e.EOL="\n",e.homedir=function(){return"/"}},function(t){"use strict";t.exports.parse=function(t){var e={},n=t.split("\r\n"),r=!1;return n.forEach(function(t){var n=new String(t);if(n.startsWith("{"))r=!0,e.body=n;else if(r)e.body+=n;else{var i=n.split(":");2===i.length&&(e[i[0].trim().toLowerCase()]=i[1].trim())}}),e}},function(t){"use strict";function e(t,n,r){var i=this,o=n.byteLength,s=t+32e3,u=n.slice(t,s);return this.sendChunk(u),s<o?(t=s,void setTimeout(function(){return e.call(i,t,n,r)},200)):r()}t.exports=function(t){var n=this;return new Promise(function(r,i){t&&t.byteLength||i(new Error("could not send File: not a valid ArrayBuffer")),n.telemetry.Metrics.push({Start:(new Date).toISOString(),Name:"Microphone",End:""}),e.call(n,0,t,r)})}},function(t,e,n){"use strict";(function(e){function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(){function t(t,e){for(var n,r=0;r<e.length;r++)n=e[r],n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();t.exports=function(t){var u,a=t.websocket,f=t.uuid,c=t.fetch,h=t.eventEmitter,l=t.protocolHelper,p=t.messageParser,g=t.sendFile,y=e&&e.env&&"false",d={"turn.start":[],"speech.startDetected":[],"speech.hypothesis":[],"speech.endDetected":[],"speech.phrase":[],"speech.fragment":[],"turn.end":[]},v=["turn.start","turn.end","speech.phrase","speech.hypothesis","speech.fragment"],w={format:"simple",language:"en-US",mode:"conversation",issueTokenUrl:"https://api.cognitive.microsoft.com/sts/v1.0/issueToken",accessToken:null};return function(e){function m(e){n(this,m);var i=r(this,(m.__proto__||Object.getPrototypeOf(m)).call(this));i.options=Object.assign({},w,e),u=i.options.debug||y?t.debug:function(){};var o="wss://speech.platform.bing.com/speech/recognition/"+i.options.mode+"/cognitiveservices/v1?language="+i.options.language+"&format="+i.options.format;return i.customSpeech=!!i.options.serviceUrl,i.serviceUrl=i.options.serviceUr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you can search for var i=new a(n);
dist/MsBingSpeechService.js
Outdated
var K=r(6),Z=r(7),Q=r(8);e.Buffer=o,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=n(),o.poolSize=8192,o._augment=function(t){return t.__proto__=o.prototype,t},o.from=function(t,e,r){return s(null,t,e,r)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(t,e,r){return a(null,t,e,r)},o.allocUnsafe=function(t){return f(null,t)},o.allocUnsafeSlow=function(t){return f(null,t)},o.isBuffer=function(t){return!(null==t||!t._isBuffer)},o.compare=function(t,e){if(!o.isBuffer(t)||!o.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Q(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=o.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var s=t[r];if(!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},o.byteLength=d,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},o.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?x(this,0,t):v.apply(this,arguments)},o.prototype.equals=function(t){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},o.prototype.compare=function(t,e,r,n,i){if(!o.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var s=i-n,u=r-e,a=Math.min(s,u),f=this.slice(n,i),c=t.slice(e,r),h=0;h<a;++h)if(f[h]!==c[h]){s=f[h],u=c[h];break}return s<u?-1:u<s?1:0},o.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},o.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},o.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},o.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return A(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return T(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;o.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=o.prototype;else{var i=e-t;n=new o(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+t]}return n},o.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},o.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},o.prototype.readUInt8=function(t,e){return e||M(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return e||M(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return e||M(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUInt32BE=function(t,e){return e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},o.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||M(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},o.prototype.readInt8=function(t,e){return e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){e||M(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(t,e){e||M(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(t,e){return e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return e||M(t,4,this.length),Z.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return e||M(t,4,this.length),Z.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return e||M(t,8,this.length),Z.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return e||M(t,8,this.length),Z.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){I(this,t,e,r,Math.pow(2,8*r)-1,0)}var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},o.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){I(this,t,e,r,Math.pow(2,8*r)-1,0)}var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},o.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,1,255,0),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},o.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},o.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):Y(this,t,e,!0),e+4},o.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Y(this,t,e,!1),e+4},o.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=0,s=1,u=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===u&&0!==this[e+o-1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},o.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=r-1,s=1,u=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},o.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,1,127,-128),o.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},o.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},o.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Y(this,t,e,!0),e+4},o.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),o.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):Y(this,t,e,!1),e+4},o.prototype.writeFloatLE=function(t,e,r){return j(this,t,e,!0,r)},o.prototype.writeFloatBE=function(t,e,r){return j(this,t,e,!1,r)},o.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},o.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},o.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;i>=0;--i)t[i+e]=this[i+r];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},o.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var s;if("number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var u=o.isBuffer(t)?t:G(new o(t,n).toString()),a=u.length;for(s=0;s<r-e;++s)this[s+e]=u[s%a]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(e,r(5))},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";function n(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function i(t){return 3*t.length/4-n(t)}function o(t){var e,r,i,o,s,u=t.length;o=n(t),s=new h(3*u/4-o),r=o>0?u-4:u;var a=0;for(e=0;e<r;e+=4)i=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],s[a++]=i>>16&255,s[a++]=i>>8&255,s[a++]=255&i;return 2===o?(i=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,s[a++]=255&i):1===o&&(i=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,s[a++]=i>>8&255,s[a++]=255&i),s}function s(t){return f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}function u(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(s(n));return i.join("")}function a(t){for(var e,r=t.length,n=r%3,i="",o=[],s=0,a=r-n;s<a;s+=16383)o.push(u(t,s,s+16383>a?a:s+16383));return 1===n?(e=t[r-1],i+=f[e>>2],i+=f[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=f[e>>10],i+=f[e>>4&63],i+=f[e<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=i,e.toByteArray=o,e.fromByteArray=a;for(var f=[],c=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,g=l.length;p<g;++p)f[p]=l[p],c[l.charCodeAt(p)]=p;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var o,s,u=8*i-n-1,a=(1<<u)-1,f=a>>1,c=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[e+h],h+=l,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=l,c-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=f}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,u,a,f=8*o-i-1,c=(1<<f)-1,h=c>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,g=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),e+=s+h>=1?l/a:l*Math.pow(2,1-h),e*a>=2&&(s++,a/=2),s+h>=c?(u=0,s=c):s+h>=1?(u=(e*a-1)*Math.pow(2,i),s+=h):(u=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&u,p+=g,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[r+p]=255&s,p+=g,s/=256,f-=8);t[r+p-g]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){e.endianness=function(){return"LE"},e.hostname=function(){return"undefined"!=typeof location?location.hostname:""},e.loadavg=function(){return[]},e.uptime=function(){return 0},e.freemem=function(){return Number.MAX_VALUE},e.totalmem=function(){return Number.MAX_VALUE},e.cpus=function(){return[]},e.type=function(){return"Browser"},e.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},e.networkInterfaces=e.getNetworkInterfaces=function(){return{}},e.arch=function(){return"javascript"},e.platform=function(){return"browser"},e.tmpdir=e.tmpDir=function(){return"/tmp"},e.EO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var i=new u(r);
dist/MsBingSpeechService.min.js
Outdated
r.Buffer=u,r.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},r.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0===n.TYPED_ARRAY_SUPPORT?function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}():n.TYPED_ARRAY_SUPPORT,r.kMaxLength=o(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,n){return f(null,t,e,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return c(null,t,e,n)},u.allocUnsafe=function(t){return h(null,t)},u.allocUnsafeSlow=function(t){return h(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Q(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch((t+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!et(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=u.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var o=t[n];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},u.byteLength=v,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(0!=t%2)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)w(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(0!=t%4)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(0!=t%8)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?k(this,0,t):m.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,n,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),0>e||n>t.length||0>r||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,s=n-e,f=Q(o,s),a=this.slice(r,i),c=t.slice(e,n),h=0;h<f;++h)if(a[h]!==c[h]){o=a[h],s=c[h];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return b(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return b(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),0<t.length&&(0>n||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return A(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return T(this,t,e,n);case"latin1":case"binary":return R(this,t,e,n);case"base64":return S(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var nt=4096;u.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,0>t?0>(t+=n)&&(t=0):t>n&&(t=n),0>e?0>(e+=n)&&(e=0):e>n&&(e=n),e<t&&(e=t);var r;if(u.TYPED_ARRAY_SUPPORT)r=this.subarray(t,e),r.__proto__=u.prototype;else{var i=e-t;r=new u(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||Y(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);)r+=this[t+o]*i;return r},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||Y(t,e,this.length);for(var r=this[t+--e],i=1;0<e&&(i*=256);)r+=this[t+--e]*i;return r},u.prototype.readUInt8=function(t,e){return e||Y(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||Y(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||Y(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||Y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||Y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(e,n,r){e|=0,n|=0,r||Y(e,n,this.length);for(var i=this[e],o=1,s=0;++s<n&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=t(2,8*n)),i},u.prototype.readIntBE=function(e,n,r){e|=0,n|=0,r||Y(e,n,this.length);for(var i=n,o=1,s=this[e+--i];0<i&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=t(2,8*n)),s},u.prototype.readInt8=function(t,e){return e||Y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||Y(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){e||Y(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return e||Y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||Y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||Y(t,4,this.length),tt.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||Y(t,4,this.length),tt.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||Y(t,8,this.length),tt.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||Y(t,8,this.length),tt.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(e,n,r,i){if(e=+e,n|=0,r|=0,!i){D(this,e,n,r,t(2,8*r)-1,0)}var o=1,s=0;for(this[n]=255&e;++s<r&&(o*=256);)this[n+s]=255&e/o;return n+r},u.prototype.writeUIntBE=function(e,n,r,i){if(e=+e,n|=0,r|=0,!i){D(this,e,n,r,t(2,8*r)-1,0)}var o=r-1,s=1;for(this[n+o]=255&e;0<=--o&&(s*=256);)this[n+o]=255&e/s;return n+r},u.prototype.writeUInt8=function(t,n,r){return t=+t,n|=0,r||D(this,t,n,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=e(t)),this[n]=255&t,n+1},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):j(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},u.prototype.writeIntLE=function(e,n,r,i){if(e=+e,n|=0,!i){var o=t(2,8*r-1);D(this,e,n,r,o-1,-o)}var s=0,u=1,f=0;for(this[n]=255&e;++s<r&&(u*=256);)0>e&&0==f&&0!==this[n+s-1]&&(f=1),this[n+s]=255&(e/u>>0)-f;return n+r},u.prototype.writeIntBE=function(e,n,r,i){if(e=+e,n|=0,!i){var o=t(2,8*r-1);D(this,e,n,r,o-1,-o)}var s=r-1,u=1,f=0;for(this[n+s]=255&e;0<=--s&&(u*=256);)0>e&&0==f&&0!==this[n+s+1]&&(f=1),this[n+s]=255&(e/u>>0)-f;return n+r},u.prototype.writeInt8=function(t,n,r){return t=+t,n|=0,r||D(this,t,n,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=e(t)),0>t&&(t=255+t+1),this[n]=255&t,n+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):C(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):C(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):j(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):j(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,n){return N(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return N(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return F(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return F(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),0<r&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;0<=i;--i)t[i+e]=this[i+n];else if(1e3>o||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);256>i&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(0>e||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0);var o;if("number"==typeof t)for(o=e;o<n;++o)this[o]=t;else{var s=u.isBuffer(t)?t:W(new u(t,r).toString()),f=s.length;for(o=0;o<n-e;++o)this[o+e]=s[o%f]}return this};var rt=/[^+\/0-9A-Za-z-_]/g}).call(r,i(5))},function(t){var e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,e){"use strict";function n(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function r(t){return o[63&t>>18]+o[63&t>>12]+o[63&t>>6]+o[63&t]}function i(t,e,n){for(var i,o=[],s=e;s<n;s+=3)i=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(r(i));return o.join("")}e.byteLength=function(t){return 3*t.length/4-n(t)},e.toByteArray=function(t){var e,r,i,o,f,a=t.length;o=n(t),f=new u(3*a/4-o),r=0<o?a-4:a;var c=0;for(e=0;e<r;e+=4)i=s[t.charCodeAt(e)]<<18|s[t.charCodeAt(e+1)]<<12|s[t.charCodeAt(e+2)]<<6|s[t.charCodeAt(e+3)],f[c++]=255&i>>16,f[c++]=255&i>>8,f[c++]=255&i;return 2===o?(i=s[t.charCodeAt(e)]<<2|s[t.charCodeAt(e+1)]>>4,f[c++]=255&i):1===o&&(i=s[t.charCodeAt(e)]<<10|s[t.charCodeAt(e+1)]<<4|s[t.charCodeAt(e+2)]>>2,f[c++]=255&i>>8,f[c++]=255&i),f},e.fromByteArray=function(t){for(var e,n=t.length,r=n%3,s="",u=[],f=16383,a=0,c=n-r;a<c;a+=f)u.push(i(t,a,a+f>c?c:a+f));return 1==r?(e=t[n-1],s+=o[e>>2],s+=o[63&e<<4],s+="=="):2==r&&(e=(t[n-2]<<8)+t[n-1],s+=o[e>>10],s+=o[63&e>>4],s+=o[63&e<<2],s+="="),u.push(s),u.join("")};for(var o=[],s=[],u="undefined"==typeof Uint8Array?Array:Uint8Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=f.length;a<c;++a)o[a]=f[a],s[f.charCodeAt(a)]=a;s[45]=62,s[95]=63},function(n,r){r.read=function(e,n,r,i,o){var s,u,f=8*o-i-1,a=(1<<f)-1,c=a>>1,h=-7,l=r?o-1:0,p=r?-1:1,g=e[n+l];for(l+=p,s=g&(1<<-h)-1,g>>=-h,h+=f;0<h;s=256*s+e[n+l],l+=p,h-=8);for(u=s&(1<<-h)-1,s>>=-h,h+=i;0<h;u=256*u+e[n+l],l+=p,h-=8);if(0===s)s=1-c;else{if(s===a)return u?NaN:1/0*(g?-1:1);u+=t(2,i),s-=c}return(g?-1:1)*u*t(2,s-i)},r.write=function(n,r,i,o,s,u){var f,a,c,h=8*u-s-1,l=(1<<h)-1,p=l>>1,g=23===s?5.960464477539062e-8:0,y=o?0:u-1,d=o?1:-1,v=0>r||0===r&&0>1/r?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(a=isNaN(r)?1:0,f=l):(f=e(Math.log(r)/Math.LN2),1>r*(c=t(2,-f))&&(f--,c*=2),r+=1<=f+p?g/c:g*t(2,1-p),2<=r*c&&(f++,c/=2),f+p>=l?(a=0,f=l):1<=f+p?(a=(r*c-1)*t(2,s),f+=p):(a=r*t(2,p-1)*t(2,s),f=0));8<=s;n[i+y]=255&a,y+=d,a/=256,s-=8);for(f=f<<s|a,h+=s;0<h;n[i+y]=255&f,y+=d,f/=256,h-=8);n[i+y-d]|=128*v}},function(t){var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},function(t,e){var n=Number.MAX_VALUE;e.endianness=function(){return"LE"},e.hostname=function(){return"undefined"==typeof location?"":location.hostname},e.loadavg=function(){return[]},e.uptime=function(){return 0},e.freemem=function(){return n},e.totalmem=function(){return n},e.cpus=function(){return[]},e.type=function(){return"Browser"},e.release=function(){return"undefined"==typeof navigator?"":navigator.appVersion},e.networkInterfaces=e.getNetworkInterfaces=function(){return{}},e.arch=function(){return"javascript"},e.platform=function(){return"browser"},e.tmpdir=e.tmpDir=function(){return"/tmp"},e.EOL="\n",e.homedir=function(){return"/"}},function(t){"use strict";t.exports.parse=function(t){var e={},n=t.split("\r\n"),r=!1;return n.forEach(function(t){var n=new String(t);if(n.startsWith("{"))r=!0,e.body=n;else if(r)e.body+=n;else{var i=n.split(":");2===i.length&&(e[i[0].trim().toLowerCase()]=i[1].trim())}}),e}},function(t){"use strict";function e(t,n,r){var i=this,o=n.byteLength,s=t+32e3,u=n.slice(t,s);return this.sendChunk(u),s<o?(t=s,void setTimeout(function(){return e.call(i,t,n,r)},200)):r()}t.exports=function(t){var n=this;return new Promise(function(r,i){t&&t.byteLength||i(new Error("could not send File: not a valid ArrayBuffer")),n.telemetry.Metrics.push({Start:(new Date).toISOString(),Name:"Microphone",End:""}),e.call(n,0,t,r)})}},function(t,e,n){"use strict";(function(e){function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(){function t(t,e){for(var n,r=0;r<e.length;r++)n=e[r],n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();t.exports=function(t){var u,f=t.websocket,a=t.uuid,c=t.fetch,h=t.eventEmitter,l=t.protocolHelper,p=t.messageParser,g=t.sendFile,y=e&&e.env&&"false",d={"turn.start":[],"speech.startDetected":[],"speech.hypothesis":[],"speech.endDetected":[],"speech.phrase":[],"speech.fragment":[],"turn.end":[]},v=["turn.start","turn.end","speech.phrase","speech.hypothesis","speech.fragment"],m={format:"simple",language:"en-US",mode:"conversation",issueTokenUrl:"https://api.cognitive.microsoft.com/sts/v1.0/issueToken",accessToken:null};return function(e){function w(e){n(this,w);var i=r(this,(w.__proto__||Object.getPrototypeOf(w)).call(this));i.options=Object.assign({},m,e),u=i.options.debug||y?t.debug:function(){};var o="wss://speech.platform.bing.com/speech/recognition/"+i.options.mode+"/cognitiveservices/v1?language="+i.options.language+"&format="+i.options.format;return i.customSpeech=!!i.options.serviceUrl,i.serviceUrl=i.options.serviceUrl||o,i.issueTokenUrl=i.options.issueTokenUrl,i.telemetry={Metrics:[],ReceivedMessages:d},i.currentTurnGuid=a().replace(/-/g,""),Object.assign(f.prototype,h.prototype),i}return i(w,e),s(w,[{key:"_resetT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var i=new f(n);
@@ -7,6 +7,14 @@ | |||
"node": "4" | |||
} | |||
}] | |||
], | |||
"plugins": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added two Babel plugins.
Without this plugin, we would have something like:
var client = process.env.BABEL_ENV === 'node' ? new websocket(authorizedServiceUrl, null, null, headerParams) : new websocket(authorizedServiceUrl);
With the babel-plugin-transform-inline-environment-variables, it will become:
var client = 'node' === 'node' ? new websocket(authorizedServiceUrl, null, null, headerParams) : new websocket(authorizedServiceUrl);
Next, with the babel-plugin-minify-dead-code-elimination, the part that never be reached will be deleted
Hi @noopkat I've updated the PR. Now, it will determine based on the As an extra, I've made sure that the death part is eliminated from the build. Thanks for reviewing! 😊 |
I'm facing another issue that there is no way to pass an Authorization Header using https://developer.mozilla.org/en-US/docs/Web/API/WebSocket to pass an access_token. Maybe using a package like https://github.com/theturtle32/WebSocket-Node can help (it has browser support), and there is an option to pass headers: https://github.com/theturtle32/WebSocket-Node/blob/master/docs/WebSocketClient.md#methods This library is also used in the Javascript SDK of IBM Watson Speech To Text: |
@DemianD thanks for looking into this on a deeper level! One catch is that we're already using WebSocket-Node, but as covered in the docs we can't use the auth headers which is super annoying:
So we still need to support the query params for the browser, but also be able to utilise the auth headers in the use case of Custom Speech Service running within NodeJS. What I'd like to implement / see implemented is a smarter and more encapsulated way of judging at runtime if custom speech service is being used by the developer, without asking them for any further properties or requiring any API changes. This way, we can have a more robust way of being able to switch to using those auth headers in that specific case. Thanks for sticking around with this pull request - I feel it's getting super close and I love the work so far ✨ |
Hi @DemianD, Thanks for this contribution, and apologies that it didn't get merged in the end. Therefore I'll respectfully close this pull request and will be deprecating / archive this repo 🙇♀ Thanks again for your contribution. |
In Chrome, I get an error:
This is caused by passing
null
parameters when creating a WebSocket.But these parameters are necessary for the WebSocket in the Node.JS implementation. I'm not sure how I can fix this
Looking forward for feedback :)