AudioWorklet processor that streams audio samples to the main thread.
// Source: https://github.com/aaif-goose/goose | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// AudioWorklet processor for capturing audio samples
class AudioCaptureProcessor extends AudioWorkletProcessor {
process(inputs) {
const ch = inputs[0]?.[0];
if (ch?.length > 0) {
this.port.postMessage(new Float32Array(ch));
}
return true;
}
}
registerProcessor('audio-capture', AudioCaptureProcessor);
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key