moeru-ai/airi · error · Error
Failed to initialize speech provider
Error message
Failed to initialize speech provider
What it means
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.
Source
Thrown at packages/stage-pages/src/pages/settings/providers/speech/kokoro-local.vue:80
config.model = val
},
})
// Model options for the dropdown
const modelOptions = computed(() => {
return providerModels.value.map(m => ({
label: m.name,
value: m.id,
}))
})
// Generate speech with Kokoro-specific parameters
async function handleGenerateSpeech(input: string, voiceId: string, _useSSML: boolean) {
try {
const provider = await providersStore.getProviderInstance(providerId) as SpeechProvider
if (!provider) {
console.error('[Kokoro Playground] Failed to get provider instance')
throw new Error('Failed to initialize speech provider')
}
const config = providerStore.getProviderConfig(providerId)
const selectedModel = config.model as string | undefined || defaultModel
const result = await speechStore.speech(
provider,
selectedModel,
input,
voiceId,
{
...config,
},
)
return result
}
catch (error) {View on GitHub (pinned to 677329427f)
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.
Example fix
// before
const provider = await providersStore.getProviderInstance(providerId) as SpeechProvider
if (!provider) {
console.error('[Kokoro Playground] Failed to get provider instance')
throw new Error('Failed to initialize speech provider')
}
// after
const provider = await providersStore.getProviderInstance(providerId) as SpeechProvider
if (!provider || typeof provider.speech !== 'function') {
console.error('[Kokoro Playground] Failed to get provider instance', { webgpu: !!navigator.gpu })
throw new Error('Kokoro local runtime unavailable — ensure WebGPU is enabled and the model is loaded')
} Defensive patterns
Strategy: validation
Validate before calling
const runtimeReady = computed(() => !!navigator.gpu) // WebGPU present
const modelReady = computed(() => !!providerStore.getProviderConfig(providerId)?.model)
if (!runtimeReady.value)
throw new Error('Kokoro requires a WebGPU-capable browser') Type guard
function isSpeechProvider(v: unknown): v is SpeechProvider {
return typeof v === 'object' && v !== null && typeof (v as SpeechProvider).speech === 'function'
} Try / catch
try {
const provider = await providersStore.getProviderInstance(providerId)
if (!provider) { console.error('[Kokoro Playground] no instance', { webgpu: !!navigator.gpu }) }
}
catch (error) { showError(errorMessageFrom(error)) } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to initialize speech provider
- Failed to initialize speech provider
- Failed to initialize speech provider
- Failed to initialize speech provider
- Failed to initialize speech provider
AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18).
Data as JSON: /api/errors/2b4dc715e11dca31.
Report an issue: GitHub.