moeru-ai/airi · error · Error

Failed to initialize speech provider

Error message

Failed to initialize speech provider

What it means

The CometAPI speech preview awaits getProviderInstance(providerId) cast to SpeechProvider<string> and throws this generic message on a falsy instance. Usually the missing-credentials throw from provider.ts fires first when no API key is saved (onMounted only defaults model and voice); this guard covers a factory returning nothing.

Source

Thrown at packages/stage-pages/src/pages/settings/providers/speech/comet-api-speech.vue:103

// Ensure provider config is initialized on mount
onMounted(() => {
  if (!providers.value[providerId]) {
    providers.value[providerId] = {}
  }
  if (!providers.value[providerId].model) {
    providers.value[providerId].model = defaultModel
  }
  if (!providers.value[providerId].voice) {
    providers.value[providerId].voice = 'alloy'
  }
})

// Generate speech with OpenAI-compatible parameters
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')
  }

  // Get provider configuration
  const providerConfig = providerStore.getProviderConfig(providerId)

  // Use the reactive model computed property (not a local variable)
  const modelToUse = modelId || model.value || defaultModel

  return await speechStore.speech(
    provider,
    modelToUse,
    input,
    voiceId || (voice.value as string),
    {
      ...providerConfig,
      ...defaultVoiceSettings,
      speed: speed.value,
    },

View on GitHub (pinned to 677329427f)

Solutions

  1. Save the CometAPI credentials in Settings > Providers > Speech and retry.
  2. Verify providerId matches the registered OpenAI-compatible speech definition.
  3. Gate the generate button on credential presence.
  4. Surface the underlying provider error instead of the generic message for diagnosis.
Defensive patterns

Strategy: validation

Validate before calling

if (!providers.value[providerId]?.apiKey) {
  // provider unconfigured — disable generate and link to settings
}

Try / catch

catch (e) {
  const msg = errorMessageFrom(e) ?? ''
  if (msg.includes('credentials') || msg.includes('initialize speech provider'))
    openProviderSettings(providerId)
  else
    throw e
}

Prevention

When it happens

Trigger: Clicking generate before configuring the CometAPI credentials; onMounted defaults (defaultModel, voice 'alloy') applied while the API key is still absent.

Common situations: Fresh install with the speech provider selected but unconfigured; tests exercising the page without seeded credentials.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/016fef101e62bdd3. Report an issue: GitHub.