moeru-ai/airi · error · Error

Failed to initialize voice activity detection.

Error message

Failed to initialize voice activity detection.

What it means

After vad.init() (the ONNX voice-activity-detection model plus its AudioWorklet, see stores/ai/models/vad.ts), vad.loaded is still false, so the session throws. The message is vad.inferenceError.value when the VAD worker reported a concrete failure (model download error, worklet error), otherwise this generic fallback.

Source

Thrown at packages/stage-ui/src/stores/modules/hearing.ts:980

      stop: async () => {
        await finishRealtimeTranscription()
      },
      onError: (err) => {
        error.value = errorMessage(err)
        console.error('Error managing VAD streaming transcription:', error.value)
      },
    })
    vadSession = {
      vad,
      lifecycle,
      providerId,
      callbacks: streamingCallbacks,
    }
    streamingVadSession.value = vadSession

    await vad.init()
    if (!vad.loaded.value) {
      throw new Error(vad.inferenceError.value || 'Failed to initialize voice activity detection.')
    }

    await vad.start(stream)
  }

  async function transcribeForMediaStream(stream: MediaStream, options: MediaStreamTranscriptionOptions) {
    console.info('[Hearing Pipeline] transcribeForMediaStream called', {
      supportsStreamInput: supportsStreamInput.value,
      hasStream: !!stream,
      providerId: activeTranscriptionProvider.value,
      hasCallbacks: !!(options.onSentenceEnd || options.onSpeechEnd || options.onTranscriptionUpdate),
    })

    if (!supportsStreamInput.value) {
      console.warn('[Hearing Pipeline] Stream input not supported')
      return
    }

View on GitHub (pinned to b6d0809ecb)

Solutions

  1. Check the devtools network tab and confirm the VAD model and process.worklet assets load; unblock and retry.
  2. Log vad.inferenceError.value right after init — it carries the real underlying failure.
  3. Verify the '../../workers/vad/process.worklet?worker&url' import resolves in the current Vite build.
  4. Clear caches / go online and let init retry on the next transcription start.
Defensive patterns

Strategy: fallback

Validate before calling

const canRunVad = typeof AudioWorkletNode !== 'undefined'
  && typeof WebAssembly === 'object'
  && (navigator.onLine || vadWasLoaded)
if (!canRunVad) {
  // skip the VAD path, use plain streaming transcription
}

Try / catch

try {
  await vad.init()
  if (!vad.loaded.value)
    throw new Error(vad.inferenceError.value || 'Failed to initialize voice activity detection.')
  await vad.start(stream)
}
catch (e) {
  // degrade gracefully: transcription without VAD segmentation
  await startStreamingTranscriptionWithoutVad(stream)
}

Prevention

When it happens

Trigger: Starting VAD-based mic transcription when VAD assets fail to load: network blocks the ONNX model download, the vad/process.worklet worker URL does not resolve in the current build, or the worker errored during runtime init (setting inferenceError).

Common situations: First use on a restricted or proxied network; build/HMR breakage of the worklet asset import; browsers without AudioWorklet or WebAssembly; service worker caching a stale model.

Related errors


AI-assisted analysis of moeru-ai/airi@b6d0809ecb (2026-08-18). Data as JSON: /api/errors/7d3afcecdc5fffcf. Report an issue: GitHub.