From eae942702cd56d3e20b289262b59a6da957a1e11 Mon Sep 17 00:00:00 2001 From: RainbowBird Date: Sun, 7 Jun 2026 01:55:34 +0800 Subject: [PATCH] feat(speech): enhance voice pack handling and add computed properties for UI logic --- .../src/pages/settings/modules/speech.vue | 114 +++++++++--------- .../stage-ui/src/components/scenes/Stage.vue | 4 +- .../src/stores/modules/speech.test.ts | 46 ++++++- .../stage-ui/src/stores/modules/speech.ts | 7 ++ 4 files changed, 112 insertions(+), 59 deletions(-) diff --git a/packages/stage-pages/src/pages/settings/modules/speech.vue b/packages/stage-pages/src/pages/settings/modules/speech.vue index c24ba2db9..2874a0655 100644 --- a/packages/stage-pages/src/pages/settings/modules/speech.vue +++ b/packages/stage-pages/src/pages/settings/modules/speech.vue @@ -15,7 +15,7 @@ import { import { useAnalytics } from '@proj-airi/stage-ui/composables' import { OFFICIAL_SPEECH_PROVIDER_ID } from '@proj-airi/stage-ui/libs/providers/providers/official' import { useAiriCardStore, useVoicePacksStore } from '@proj-airi/stage-ui/stores' -import { useSpeechStore } from '@proj-airi/stage-ui/stores/modules/speech' +import { useSpeechStore, voicePackForSpeechProvider } from '@proj-airi/stage-ui/stores/modules/speech' import { useProvidersStore } from '@proj-airi/stage-ui/stores/providers' import { FieldCheckbox, @@ -26,7 +26,7 @@ import { } from '@proj-airi/ui' import { generateSpeech } from '@xsai/generate-speech' import { storeToRefs } from 'pinia' -import { onMounted, onUnmounted, ref, watch } from 'vue' +import { computed, onMounted, onUnmounted, ref, watch } from 'vue' import { useI18n } from 'vue-i18n' import { RouterLink } from 'vue-router' @@ -66,6 +66,12 @@ const audioUrl = ref('') const audioPlayer = ref(null) const errorMessage = ref('') +const supportsVoicePackSelection = computed(() => activeSpeechProvider.value === OFFICIAL_SPEECH_PROVIDER_ID) +const shouldShowVoicePackSection = computed(() => + supportsVoicePackSelection.value + && (isLoadingVoicePacks.value || voicePacksError.value != null || voicePacks.value.length > 0), +) + function createVoicePackVoice(voicePack: VoicePackSnapshot): VoiceInfo { return { id: voicePack.voiceId, @@ -186,7 +192,7 @@ async function generateTestSpeech() { } } - const voicePack = activeCard.value?.extensions.airi.modules.speech.voicePack + const voicePack = voicePackForSpeechProvider(activeSpeechProvider.value, activeCard.value?.extensions.airi.modules.speech.voicePack) if (voicePack) { model = voicePack.ttsModelId if (!voice || voice.id !== voicePack.voiceId) @@ -318,61 +324,57 @@ function handleDeleteProvider(providerId: string) {
-
-

- {{ t('settings.pages.modules.speech.sections.section.voice-pack.title') }} -

-
- {{ t('settings.pages.modules.speech.sections.section.voice-pack.description') }} -
-
- -
-
- {{ t('settings.pages.modules.speech.sections.section.voice-pack.loading') }} -
- - - -
-