moeru-ai/airi · error · Error
Failed to initialize speech provider
Error message
Failed to initialize speech provider
What it means
The speech-preview handler for Alibaba Cloud Model Studio awaits providersStore.getProviderInstance(providerId) and throws this generic message when it resolves falsy. In practice construction usually fails earlier with the credentials error from provider.ts when the API key is missing; this guard covers factories that return nothing. The surrounding code is a shared template (it references ElevenLabs option types).
Source
Thrown at packages/stage-pages/src/pages/settings/providers/speech/alibaba-cloud-model-studio.vue:47
const speechStore = useSpeechStore()
const providersStore = useProviderStore()
const providerStore = useProviderConfigStore()
const { configs: providers } = storeToRefs(providerStore)
const { t } = useI18n()
// Check if API key is configured
const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)
// Get available voices for ElevenLabs
const availableVoices = computed(() => {
return speechStore.availableVoices[providerId] || []
})
// Generate speech with ElevenLabs-specific parameters
async function handleGenerateSpeech(input: string, voiceId: string, _useSSML: boolean) {
const provider = await providersStore.getProviderInstance(providerId) as SpeechProviderWithExtraOptions<string, UnElevenLabsOptions>
if (!provider) {
throw new Error('Failed to initialize speech provider')
}
// Get provider configuration
const providerConfig = providerStore.getProviderConfig(providerId)
// Get model from configuration or use default
const model = providerConfig.model as string | undefined || defaultModel
// ElevenLabs doesn't need SSML conversion, but if SSML is provided, use it directly
return await speechStore.speech(
provider,
model,
input,
voiceId,
{
...providerConfig,
...defaultVoiceSettings,
},View on GitHub (pinned to 677329427f)
Solutions
- Save the provider API key in Settings > Providers > Speech (the apiKeyConfigured computed reads the same state).
- Confirm providerId matches a registered speech definition.
- Catch the credentials error from getProviderInstance and link the user to provider settings.
- Keep the generate action disabled until apiKeyConfigured is true.
Example fix
// before
const provider = await providersStore.getProviderInstance(providerId)
if (!provider)
throw new Error('Failed to initialize speech provider')
// after
if (!apiKeyConfigured.value)
throw new Error('Configure the provider API key in Settings before generating speech')
const provider = await providersStore.getProviderInstance(providerId)
if (!provider)
throw new Error(`Speech provider "${providerId}" factory returned no instance`) Defensive patterns
Strategy: validation
Validate before calling
const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)
if (!apiKeyConfigured.value) {
// disable the generate button / prompt provider settings
} Try / catch
catch (e) {
if (errorMessageFrom(e)?.includes('credentials'))
openProviderSettings(providerId)
else
throw e
} Prevention
- Gate all speech-preview buttons on apiKeyConfigured.
- Share one guarded generate handler across speech provider pages instead of copy-pasting templates.
- Surface the underlying provider error verbatim for diagnosis.
When it happens
Trigger: Clicking generate/test speech before saving the provider's API key in Settings > Providers > Speech; providerId not matching a registered speech definition.
Common situations: Fresh install with no speech credentials; switching speech provider without configuring it; stale providerId from an older version.
Related errors
- Failed to initialize speech provider
- MiniMax TTS request failed: ${response.status} ${response.st
- OpenRouter audio request failed: ${response.status} ${await
- Vision provider/model not configured
- Failed to initialize speech provider
AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18).
Data as JSON: /api/errors/a74faddc0a25abeb.
Report an issue: GitHub.