fix(stage-ui): fix transcription session callback reuse and auto-send issues (#996)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user