@absolutejs/voice 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -539,12 +539,19 @@ var createMicrophoneCapture = (options) => {
539
539
  let processorNode = null;
540
540
  let mediaStream = null;
541
541
  const start = async () => {
542
+ if (typeof navigator === "undefined" || !navigator.mediaDevices?.getUserMedia) {
543
+ throw new Error("Browser microphone capture requires navigator.mediaDevices.getUserMedia.");
544
+ }
545
+ const AudioContextCtor = (typeof window !== "undefined" ? window.AudioContext ?? window.webkitAudioContext : undefined) ?? AudioContext;
546
+ if (!AudioContextCtor) {
547
+ throw new Error("Browser microphone capture requires AudioContext support.");
548
+ }
542
549
  mediaStream = await navigator.mediaDevices.getUserMedia({
543
550
  audio: {
544
551
  channelCount: options.channelCount ?? 1
545
552
  }
546
553
  });
547
- audioContext = new AudioContext;
554
+ audioContext = new AudioContextCtor;
548
555
  sourceNode = audioContext.createMediaStreamSource(mediaStream);
549
556
  processorNode = audioContext.createScriptProcessor(4096, 1, 1);
550
557
  processorNode.onaudioprocess = (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",