@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.
- package/dist/client/index.js +8 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -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
|
|
554
|
+
audioContext = new AudioContextCtor;
|
|
548
555
|
sourceNode = audioContext.createMediaStreamSource(mediaStream);
|
|
549
556
|
processorNode = audioContext.createScriptProcessor(4096, 1, 1);
|
|
550
557
|
processorNode.onaudioprocess = (event) => {
|