feat(stage-tamagotchi): realtime whisper

This commit is contained in:
Neko Ayaka
2025-07-03 03:46:00 +08:00
parent af66327563
commit e2ab28cdf3
14 changed files with 1127 additions and 383 deletions
+9
View File
@@ -158,6 +158,11 @@ export function useAudioStream(cfg: MaybeRefOrGetter<AudioStreamConfig | undefin
console.error('Audio chunk callback error:', err)
}
})
// Only continue if still active
if (isActive.value) {
requestAnimationFrame(analyze)
}
}
analyze()
@@ -174,6 +179,10 @@ export function useAudioStream(cfg: MaybeRefOrGetter<AudioStreamConfig | undefin
return () => chunkCallbacks.delete(callback)
}
function stop() {
mediaStream.value?.getTracks().forEach(track => track.stop())
}
// Cleanup
onUnmounted(() => {
stop()