From 73b7ce722c3045fd4bd2029cd7e2129503b68495 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Wed, 8 Oct 2025 17:13:28 +0800 Subject: [PATCH] chore(stage-tamagotchi): small refactor & cleanup --- .../src/renderer/styles/transitions.css | 4 +- .../src/composables/use-modules-list.ts | 2 +- .../stage-ui/src/stores/modules/hearing.ts | 39 ++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/apps/stage-tamagotchi/src/renderer/styles/transitions.css b/apps/stage-tamagotchi/src/renderer/styles/transitions.css index 82ae842e3..b422ffb9f 100644 --- a/apps/stage-tamagotchi/src/renderer/styles/transitions.css +++ b/apps/stage-tamagotchi/src/renderer/styles/transitions.css @@ -1,8 +1,8 @@ .slide-away-enter-active, .slide-away-leave-active { transition: - transform 0.3s ease-in-out, - opacity 0.3s ease-in-out; + transform 0.15s ease-in-out, + opacity 0.15s ease-in-out; } .slide-away-enter, diff --git a/packages/stage-ui/src/composables/use-modules-list.ts b/packages/stage-ui/src/composables/use-modules-list.ts index a47571a36..8c1abaa1d 100644 --- a/packages/stage-ui/src/composables/use-modules-list.ts +++ b/packages/stage-ui/src/composables/use-modules-list.ts @@ -57,7 +57,7 @@ export function useModulesList() { name: t('settings.pages.modules.hearing.title'), description: t('settings.pages.modules.hearing.description'), icon: 'i-solar:microphone-3-bold-duotone', - to: '', + to: '/settings/modules/hearing', configured: false, category: 'essential', }, diff --git a/packages/stage-ui/src/stores/modules/hearing.ts b/packages/stage-ui/src/stores/modules/hearing.ts index 9cbb8a8e2..a8e4ef517 100644 --- a/packages/stage-ui/src/stores/modules/hearing.ts +++ b/packages/stage-ui/src/stores/modules/hearing.ts @@ -1,4 +1,4 @@ -import type { TranscriptionProviderWithExtraOptions } from '@xsai-ext/shared-providers' +import type { TranscriptionProvider, TranscriptionProviderWithExtraOptions } from '@xsai-ext/shared-providers' import { useLocalStorage } from '@vueuse/core' import { generateTranscription } from '@xsai/generate-transcription' @@ -88,3 +88,40 @@ export const useHearingStore = defineStore('hearing-store', () => { getModelsForProvider, } }) + +export const useHearingSpeechInputPipeline = defineStore('modules:hearing:speech:audio-input-pipeline', () => { + const error = ref() + + const hearingStore = useHearingStore() + const { activeTranscriptionProvider, activeTranscriptionModel } = storeToRefs(hearingStore) + const providersStore = useProvidersStore() + + async function transcribeForRecording(recording: Blob | null | undefined) { + if (!recording) + return + + try { + if (recording && recording.size > 0) { + const provider = await providersStore.getProviderInstance>(activeTranscriptionProvider.value) + if (!provider) { + throw new Error('Failed to initialize speech provider') + } + + // Get model from configuration or use default + const model = activeTranscriptionModel.value + const res = await hearingStore.transcription(provider, model, new File([recording], 'recording.wav')) + return res.text + } + } + catch (err) { + error.value = err instanceof Error ? err.message : String(err) + console.error('Error generating transcription:', error.value) + } + } + + return { + error, + + transcribeForRecording, + } +})