fix(stage-ui): fix transcription session callback reuse and auto-send issues (#996)

This commit is contained in:
lockrush-dev
2026-01-26 14:59:50 +08:00
committed by GitHub
parent 850792b0a1
commit 4cac97937f
5 changed files with 122 additions and 54 deletions
+5 -1
View File
@@ -46,7 +46,7 @@ const settingsAudioDeviceStore = useSettingsAudioDevice()
const { stream, enabled } = storeToRefs(settingsAudioDeviceStore)
const { startRecord, stopRecord, onStopRecord } = useAudioRecorder(stream)
const hearingPipeline = useHearingSpeechInputPipeline()
const { transcribeForRecording, transcribeForMediaStream } = hearingPipeline
const { transcribeForRecording, transcribeForMediaStream, stopStreamingTranscription } = hearingPipeline
const { supportsStreamInput } = storeToRefs(hearingPipeline)
const providersStore = useProvidersStore()
const consciousnessStore = useConsciousnessStore()
@@ -99,6 +99,8 @@ async function startAudioInteraction() {
async function handleSpeechStart() {
if (shouldUseStreamInput.value && stream.value) {
// Use both callbacks to support incremental updates and final transcript replacement.
// ChatArea uses only onSentenceEnd to avoid re-adding deleted text.
await transcribeForMediaStream(stream.value, {
onSentenceEnd: (delta) => {
const finalText = delta
@@ -139,6 +141,8 @@ function stopAudioInteraction() {
try {
stopOnStopRecord?.()
stopOnStopRecord = undefined
// Stop any active streaming transcription sessions to prevent session leakage
void stopStreamingTranscription(true)
disposeVAD()
}
catch {}
@@ -203,6 +203,7 @@ async function startAudioInteraction() {
return
}
// Use sentence deltas for live captions and speech end for final text.
await transcribeForMediaStream(stream.value, {
onSentenceEnd: (delta) => {
console.info('[Main Page] Received transcription delta:', delta)