{"record":{"id":"a74faddc0a25abeb","repo":"moeru-ai/airi","slug":"failed-to-initialize-speech-provider-a74fad","errorCode":null,"errorMessage":"Failed to initialize speech provider","messagePattern":"Failed to initialize speech provider","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-pages/src/pages/settings/providers/speech/alibaba-cloud-model-studio.vue","lineNumber":47,"sourceCode":"const speechStore = useSpeechStore()\nconst providersStore = useProviderStore()\nconst providerStore = useProviderConfigStore()\nconst { configs: providers } = storeToRefs(providerStore)\nconst { t } = useI18n()\n\n// Check if API key is configured\nconst apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)\n\n// Get available voices for ElevenLabs\nconst availableVoices = computed(() => {\n  return speechStore.availableVoices[providerId] || []\n})\n\n// Generate speech with ElevenLabs-specific parameters\nasync function handleGenerateSpeech(input: string, voiceId: string, _useSSML: boolean) {\n  const provider = await providersStore.getProviderInstance(providerId) as SpeechProviderWithExtraOptions<string, UnElevenLabsOptions>\n  if (!provider) {\n    throw new Error('Failed to initialize speech provider')\n  }\n\n  // Get provider configuration\n  const providerConfig = providerStore.getProviderConfig(providerId)\n\n  // Get model from configuration or use default\n  const model = providerConfig.model as string | undefined || defaultModel\n\n  // ElevenLabs doesn't need SSML conversion, but if SSML is provided, use it directly\n  return await speechStore.speech(\n    provider,\n    model,\n    input,\n    voiceId,\n    {\n      ...providerConfig,\n      ...defaultVoiceSettings,\n    },","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-pages/src/pages/settings/providers/speech/alibaba-cloud-model-studio.vue#L29-L65","documentation":"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).","triggerScenarios":"Clicking generate/test speech before saving the provider's API key in Settings > Providers > Speech; providerId not matching a registered speech definition.","commonSituations":"Fresh install with no speech credentials; switching speech provider without configuring it; stale providerId from an older version.","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."],"exampleFix":"// before\nconst provider = await providersStore.getProviderInstance(providerId)\nif (!provider)\n  throw new Error('Failed to initialize speech provider')\n\n// after\nif (!apiKeyConfigured.value)\n  throw new Error('Configure the provider API key in Settings before generating speech')\nconst provider = await providersStore.getProviderInstance(providerId)\nif (!provider)\n  throw new Error(`Speech provider \"${providerId}\" factory returned no instance`)","handlingStrategy":"validation","validationCode":"const apiKeyConfigured = computed(() => !!providers.value[providerId]?.apiKey)\nif (!apiKeyConfigured.value) {\n  // disable the generate button / prompt provider settings\n}","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (errorMessageFrom(e)?.includes('credentials'))\n    openProviderSettings(providerId)\n  else\n    throw e\n}","preventionTips":["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."],"tags":["speech","tts","provider","configuration"],"backgroundTag":"provider-initialization-failed","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}