Capability first · transport second

VoiceCaptureWorklet.js

Transfers continuous PCM or segments microphone samples on the audio rendering thread and transfers complete mono Float32 WAV clips to ContinuousVoiceCapture.

SDK 0.97.1Runtime 0.8.12Protocol arcane/1
On this page

Overview

Transfers continuous PCM or segments microphone samples on the audio rendering thread and transfers complete mono Float32 WAV clips to ContinuousVoiceCapture.

  • Artifact
    VoiceCaptureWorklet.js · worker
  • Classification
    internal worker
  • Availability
    AudioWorkletGlobalScope
  • Normalization
    mode:pcm emits every original sample in ordered PCM frames at the actual worklet sample rate, plus activity observations; pcmChunkMs defines transport scheduling, not a recording cap. flush returns pending PCM and a correlated flushed acknowledgement without closing the processor. The default segments mode retains rolling pre-roll, fixed 20 ms RMS activity windows independent of callback length, audio-frame quiet duration, periodic boundaries, sequence, complete original WAV audio, and stop acknowledgement. activityThreshold is RMS amplitude, not peak amplitude. Stop classifies a partial final window using its actual samples and retains softer trailing audio in the active clip. Inactive capture emits no clips; adjacent periodic clips have no repeated samples.

Import and lifecycle

JavaScript
const worker = new Worker('/node_modules/arcane-os/runtime/arcane/modules/VoiceCaptureWorklet.js');

The ContinuousVoiceCapture owner loads this static AudioWorklet processor. Audio rendering supplies microphone samples; mode:pcm transfers every sample with actual sample rate and amplitude activity events, without semantic selection. In default segment mode the processor keeps rolling pre-roll, cuts activity-bearing pause/periodic segments without overlap, and transfers complete mono Float32 WAV audio. Stop flushes the final active clip and acknowledges completion.

Application-facing behavior: No ESM exports. ContinuousVoiceCapture loads this static worklet, supplies processorOptions, receives segment or pcm/activity/flushed messages, and requests stop followed by the stopped acknowledgement.

Protocol and host implementation

AudioWorklet processor arcane-continuous-voice-capture and its owner-local MessagePort This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

This artifact has no ESM bindings. Its public load, global, asset, or worker contract is listed below.

Parameter meanings and results

Processor arcane-continuous-voice-capture receives processorOptions {preRollMs,quietMs,chunkMs,activityThreshold,mode,pcmChunkMs}. activityThreshold is RMS amplitude over fixed 20 ms audio-frame windows, not individual peaks; callback lengths do not change classification. Quiet duration counts original audio frames. Stop classifies any partial final window using its actual samples and flushes the active clip with softer trailing audio. Original samples, pre-roll and periodic adjacency are preserved. PCM mode emits {type:"pcm",audio:ArrayBuffer,sampleRate,sequence} and {type:"activity",active,audioTime}; pcmChunkMs is transport scheduling. Owner {type:"flush",id} emits pending PCM then {type:"flushed",id} without closing. Owner messages also use {type:"stop"}. Processor messages use {type:"segment",audio:ArrayBuffer,sampleRate,sequence,reason,durationMs} followed by {type:"stopped"} at stop. Inactive audio produces no clip; RMS detection does not recognize semantic speech.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

  • owner-local MessagePort segment, pcm, activity, flushed and stopped messages

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • Native AudioWorklet processor errors are observed by ContinuousVoiceCapture.

Availability and capabilities

AudioWorkletGlobalScope. mode:pcm emits every original sample in ordered PCM frames at the actual worklet sample rate, plus activity observations; pcmChunkMs defines transport scheduling, not a recording cap. flush returns pending PCM and a correlated flushed acknowledgement without closing the processor. The default segments mode retains rolling pre-roll, fixed 20 ms RMS activity windows independent of callback length, audio-frame quiet duration, periodic boundaries, sequence, complete original WAV audio, and stop acknowledgement. activityThreshold is RMS amplitude, not peak amplitude. Stop classifies a partial final window using its actual samples and retains softer trailing audio in the active clip. Inactive capture emits no clips; adjacent periodic clips have no repeated samples.

Internal AudioWorkletGlobalScope only; no ESM exports, model, persistence, or Core service. Applications use ContinuousVoiceCapture or voice-transcription.html.

Worker protocol example

JavaScript
import ContinuousVoiceCapture from '/node_modules/arcane-os/runtime/arcane/modules/ContinuousVoiceCapture.js';

const capture=new ContinuousVoiceCapture({onSegment:queueTranscription});
// ContinuousVoiceCapture owns worklet loading and the internal port.
await capture.start();
await capture.stop();

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.