moeru-ai/airi · error

Failed to initialize speech provider

Error message

Failed to initialize speech provider

What it means

Thrown by the Player2 speech playground when `getProviderInstance(providerId)` resolves falsy. Player2 is a local speech engine: unlike cloud providers it does not hinge on an API key, so a falsy build usually means the local runtime/config needed by the Player2 factory was not usable at construction time. The page even reuses the ElevenLabs option types and comments (copy-paste), but the failure mode is the same contract violation: `createProvider` returned undefined where the type promises an instance.

Source

Thrown at packages/stage-pages/src/pages/settings/providers/speech/player2-speech.vue:32

import { computed, onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'

const providerId = 'player2-speech'
const defaultModel = 'v1'
const speedRatio = ref<number>(1.0)
const speechStore = useSpeechStore()
const providersStore = useProviderStore()
const providerStore = useProviderConfigStore()
const { t } = useI18n()
// Get available voices for Player2
const availableVoices = computed(() => {
  return speechStore.availableVoices[providerId] || []
})
// Generate speech with Player2-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
  // Player2 doesn't need SSML conversion, but if SSML is provided, use it directly
  return await speechStore.speech(
    provider,
    model,
    input,
    voiceId,
    {
      ...providerConfig,
    },
  )
}
const hasPlayer2 = ref(true)
onMounted(async () => {

View on GitHub (pinned to 677329427f)

Solutions

  1. Complete the Player2 provider configuration in Settings → Providers (fill whatever local endpoint/model fields it exposes) and save.
  2. Confirm the local Player2 runtime is installed/running for your build (web vs desktop).
  3. Reload the playground after saving to rebuild the instance.
  4. Check console for `Error creating provider instance for ...` for the underlying decline reason.
  5. Report it if configuration is complete and the factory still returns nothing.

Example fix

// before
const provider = await providersStore.getProviderInstance(providerId) as SpeechProviderWithExtraOptions<string, UnElevenLabsOptions>
if (!provider)
  throw new Error('Failed to initialize speech provider')

// after
const provider = await providersStore.getProviderInstance(providerId) as SpeechProviderWithExtraOptions<string, UnElevenLabsOptions>
if (!provider || typeof provider.speech !== 'function')
  throw new Error('Player2 local engine returned no usable instance — check local runtime config and console logs')
Defensive patterns

Strategy: validation

Validate before calling

const configReady = computed(() => {
  const c = providerStore.getProviderConfig(providerId)
  return !!c && Object.values(c).some(v => typeof v === 'string' && v.trim())
})
if (!configReady.value)
  throw new Error('Complete the Player2 local engine configuration first')

Type guard

function isSpeechProvider(v: unknown): v is SpeechProviderWithExtraOptions<string> {
  return typeof v === 'object' && v !== null && typeof (v as SpeechProviderWithExtraOptions<string>).speech === 'function'
}

Try / catch

try { const provider = await providersStore.getProviderInstance(providerId) }
catch (error) { showError(errorMessageFrom(error)) }

Prevention

When it happens

Trigger: Clicking Generate before the local Player2 engine/config is set up in provider settings; blank required local config fields; environments where the Player2 runtime (local inference) is unavailable so the factory declines.

Common situations: First use of a local provider assuming zero configuration; desktop vs web build differences in local runtime availability; stale empty config object left from an aborted setup; factory silently declining on malformed values instead of throwing.

Related errors


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