moeru-ai/airi · error · Error
Failed to initialize speech provider
Error message
Failed to initialize speech provider
What it means
Thrown by the Gemini audio speech playground when `getProviderInstance<SpeechProvider<string>>(providerId)` resolves falsy before synthesis. The store resolves the Google Gemini speech definition and calls its `createProvider(config)`; the declared return type is non-nullable, so hitting this branch means the factory declined to build with the persisted config (typically a missing/blank Google API key) rather than the store's own failure paths, which throw different errors (`Provider definition ... not found`, `Provider credentials ... not found`).
Source
Thrown at packages/stage-pages/src/pages/settings/providers/speech/google-gemini-audio-speech.vue:84
})
const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)
onMounted(async () => {
ensureProviderConfig()
if (!config.value?.model)
model.value = defaultModel
await providersStore.loadModelsForConfiguredProviders()
await providersStore.fetchModelsForProvider(providerId)
await speechStore.loadVoicesForProvider(providerId)
})
async function handleGenerateSpeech(input: string, voiceId: string, _useSSML: boolean, modelId?: string) {
const provider = await providersStore.getProviderInstance<SpeechProvider<string>>(providerId)
if (!provider)
throw new Error('Failed to initialize speech provider')
const providerConfig = providerStore.getProviderConfig(providerId)
const modelToUse = modelId || model.value || defaultModel
const voiceToUse = voiceId || '' as string
return await speechStore.speech(
provider,
modelToUse,
input,
voiceToUse,
providerConfig,
)
}
const {
isValidating,
isValid,
validationMessage,View on GitHub (pinned to 677329427f)
Solutions
- Save a non-empty Google API key for this provider entry in Settings → Providers and wait for validation to pass.
- Re-enter the playground after saving so the instance is rebuilt from current config.
- Check console for the store's `Error creating provider instance for ...` log line for the underlying cause.
- Confirm you configured the audio-speech provider entry itself, not the chat/generative one — they are separate ids.
- If valid credentials still yield falsy, file an issue: the factory violates the non-nullable createProvider contract.
Example fix
// before
const provider = await providersStore.getProviderInstance<SpeechProvider<string>>(providerId)
if (!provider)
throw new Error('Failed to initialize speech provider')
// after
const config = providerStore.getProviderConfig(providerId)
if (!config?.apiKey?.trim())
throw new Error('Gemini API key is empty. Save it in provider settings first.')
const provider = await providersStore.getProviderInstance<SpeechProvider<string>>(providerId)
if (!provider || typeof provider.speech !== 'function')
throw new Error('Gemini speech factory returned no usable instance — check config and console logs') Defensive patterns
Strategy: validation
Validate before calling
const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey?.trim())
if (!apiKeyConfigured.value)
throw new Error('Save a Google API key before generating speech') Type guard
function isSpeechProvider(v: unknown): v is SpeechProvider<string> {
return typeof v === 'object' && v !== null && typeof (v as SpeechProvider<string>).speech === 'function'
} Try / catch
try { const provider = await providersStore.getProviderInstance<SpeechProvider<string>>(providerId) }
catch (error) { showError(errorMessageFrom(error)) } Prevention
- Complete provider onboarding (key + validation) before entering the playground.
- Disable generate until the onMounted model/voice loads finish.
- Confirm you configured the audio-speech provider entry, not the chat one.
When it happens
Trigger: Pressing Generate in the Gemini speech playground while `providers.value[providerId].apiKey` is blank; running before the onMounted model/voice fetches complete while credentials were never saved; config present as an object (so the store does not throw) but with unusable field values.
Common situations: New provider added without completing the API key step; key removed after a session that already used another provider; workspace where the key lives in a different provider entry (gemini chat vs gemini audio speech ids); silent factory decline on whitespace-only keys.
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/dc3a1a1fc225221f.
Report an issue: GitHub.