{"record":{"id":"7d3afcecdc5fffcf","repo":"moeru-ai/airi","slug":"failed-to-initialize-voice-activity-detection","errorCode":null,"errorMessage":"Failed to initialize voice activity detection.","messagePattern":"Failed to initialize voice activity detection\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-ui/src/stores/modules/hearing.ts","lineNumber":980,"sourceCode":"      stop: async () => {\n        await finishRealtimeTranscription()\n      },\n      onError: (err) => {\n        error.value = errorMessage(err)\n        console.error('Error managing VAD streaming transcription:', error.value)\n      },\n    })\n    vadSession = {\n      vad,\n      lifecycle,\n      providerId,\n      callbacks: streamingCallbacks,\n    }\n    streamingVadSession.value = vadSession\n\n    await vad.init()\n    if (!vad.loaded.value) {\n      throw new Error(vad.inferenceError.value || 'Failed to initialize voice activity detection.')\n    }\n\n    await vad.start(stream)\n  }\n\n  async function transcribeForMediaStream(stream: MediaStream, options: MediaStreamTranscriptionOptions) {\n    console.info('[Hearing Pipeline] transcribeForMediaStream called', {\n      supportsStreamInput: supportsStreamInput.value,\n      hasStream: !!stream,\n      providerId: activeTranscriptionProvider.value,\n      hasCallbacks: !!(options.onSentenceEnd || options.onSpeechEnd || options.onTranscriptionUpdate),\n    })\n\n    if (!supportsStreamInput.value) {\n      console.warn('[Hearing Pipeline] Stream input not supported')\n      return\n    }\n","sourceCodeStart":962,"sourceCodeEnd":998,"githubUrl":"https://github.com/moeru-ai/airi/blob/b6d0809ecb6421d492c4ce38aa7a76146c83269d/packages/stage-ui/src/stores/modules/hearing.ts#L962-L998","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check the devtools network tab and confirm the VAD model and process.worklet assets load; unblock and retry.","Log vad.inferenceError.value right after init — it carries the real underlying failure.","Verify the '../../workers/vad/process.worklet?worker&url' import resolves in the current Vite build.","Clear caches / go online and let init retry on the next transcription start."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const canRunVad = typeof AudioWorkletNode !== 'undefined'\n  && typeof WebAssembly === 'object'\n  && (navigator.onLine || vadWasLoaded)\nif (!canRunVad) {\n  // skip the VAD path, use plain streaming transcription\n}","typeGuard":null,"tryCatchPattern":"try {\n  await vad.init()\n  if (!vad.loaded.value)\n    throw new Error(vad.inferenceError.value || 'Failed to initialize voice activity detection.')\n  await vad.start(stream)\n}\ncatch (e) {\n  // degrade gracefully: transcription without VAD segmentation\n  await startStreamingTranscriptionWithoutVad(stream)\n}","preventionTips":["Feature-detect AudioWorklet and WebAssembly before enabling the VAD option.","Prefetch VAD model assets during idle time after first mount.","Treat VAD as optional and always keep a non-VAD streaming path as fallback."],"tags":["vad","audio","model-loading","browser","web-worker"],"backgroundTag":"ml-model-load-failed","analyzedSha":"b6d0809ecb6421d492c4ce38aa7a76146c83269d","analyzedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}