{"record":{"id":"2b4dc715e11dca31","repo":"moeru-ai/airi","slug":"failed-to-initialize-speech-provider-2b4dc7","errorCode":null,"errorMessage":"Failed to initialize speech provider","messagePattern":"Failed to initialize speech provider","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/providers/speech/kokoro-local.vue","lineNumber":80,"sourceCode":"    config.model = val\n  },\n})\n\n// Model options for the dropdown\nconst modelOptions = computed(() => {\n  return providerModels.value.map(m => ({\n    label: m.name,\n    value: m.id,\n  }))\n})\n\n// Generate speech with Kokoro-specific parameters\nasync function handleGenerateSpeech(input: string, voiceId: string, _useSSML: boolean) {\n  try {\n    const provider = await providersStore.getProviderInstance(providerId) as SpeechProvider\n    if (!provider) {\n      console.error('[Kokoro Playground] Failed to get provider instance')\n      throw new Error('Failed to initialize speech provider')\n    }\n\n    const config = providerStore.getProviderConfig(providerId)\n    const selectedModel = config.model as string | undefined || defaultModel\n\n    const result = await speechStore.speech(\n      provider,\n      selectedModel,\n      input,\n      voiceId,\n      {\n        ...config,\n      },\n    )\n\n    return result\n  }\n  catch (error) {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/providers/speech/kokoro-local.vue#L62-L98","documentation":"Thrown by the Kokoro (local) playground when `getProviderInstance('kokoro-local')` resolves falsy; this page additionally logs `[Kokoro Playground] Failed to get provider instance` to the console first. Kokoro runs in-browser (WebGPU-backed), so the factory can decline when the local runtime prerequisites are not met (unsupported browser, no WebGPU, model not yet loaded via `loadModel`) in addition to blank config — the factory returns undefined instead of throwing, and the page converts that into this explicit error.","triggerScenarios":"Generating speech in a browser without WebGPU or with it disabled; before the Kokoro model weights finished downloading/loading; running the web build where the local audio runtime is unavailable; a definition `isAvailableBy` gate passing while the actual factory build fails.","commonSituations":"Firefox/Safari or headless environments lacking WebGPU; first-run usage before `loadModel` completes; low GPU memory causing the runtime to bail; desktop vs web build differences in local provider availability.","solutions":["Use a Chromium-based browser with WebGPU enabled (chrome://gpu confirms availability).","Trigger the model load for Kokoro in the provider settings and wait for it to finish before generating.","Check the console for the `[Kokoro Playground]` and `Error creating provider instance for ...` lines — they carry the underlying runtime reason.","Freeze other GPU-heavy tabs and retry if memory pressure is suspected.","If WebGPU is present and loaded and it still fails, report the factory's silent-undefined behavior as a bug."],"exampleFix":"// before\nconst provider = await providersStore.getProviderInstance(providerId) as SpeechProvider\nif (!provider) {\n  console.error('[Kokoro Playground] Failed to get provider instance')\n  throw new Error('Failed to initialize speech provider')\n}\n\n// after\nconst provider = await providersStore.getProviderInstance(providerId) as SpeechProvider\nif (!provider || typeof provider.speech !== 'function') {\n  console.error('[Kokoro Playground] Failed to get provider instance', { webgpu: !!navigator.gpu })\n  throw new Error('Kokoro local runtime unavailable — ensure WebGPU is enabled and the model is loaded')\n}","handlingStrategy":"validation","validationCode":"const runtimeReady = computed(() => !!navigator.gpu) // WebGPU present\nconst modelReady = computed(() => !!providerStore.getProviderConfig(providerId)?.model)\nif (!runtimeReady.value)\n  throw new Error('Kokoro requires a WebGPU-capable browser')","typeGuard":"function isSpeechProvider(v: unknown): v is SpeechProvider {\n  return typeof v === 'object' && v !== null && typeof (v as SpeechProvider).speech === 'function'\n}","tryCatchPattern":"try {\n  const provider = await providersStore.getProviderInstance(providerId)\n  if (!provider) { console.error('[Kokoro Playground] no instance', { webgpu: !!navigator.gpu }) }\n}\ncatch (error) { showError(errorMessageFrom(error)) }","preventionTips":["Feature-detect WebGPU before showing the local provider playground.","Trigger and await the model download (loadModel) before enabling Generate.","Surface runtime availability in the UI instead of failing only at generate time."],"tags":["speech","provider","initialization","webgpu","local","kokoro"],"backgroundTag":"provider-instance-undefined","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}