From ca1ec42ea81ba4e0e7beaba9fa2043fb9722c023 Mon Sep 17 00:00:00 2001 From: Bifang <915779419@qq.com> Date: Sat, 10 Oct 2026 14:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E6=94=B6=E5=88=B0=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E5=88=86=E6=AE=B5=E7=9A=84=E6=96=B0=20partial=20?= =?UTF-8?q?=E5=BF=AB=E7=85=A7=EF=BC=8C=E9=83=BD=E4=BC=9A=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=99=E6=AE=B5=E5=8F=AF=E4=BF=AE=E8=AE=A2?= =?UTF-8?q?=E8=8D=89=E7=A8=BF=EF=BC=9B=E8=AF=A5=E5=88=86=E6=AE=B5=E5=AE=9A?= =?UTF-8?q?=E7=A8=BF=E5=90=8E=EF=BC=8C=E5=86=8D=E7=94=A8=E6=9C=80=E7=BB=88?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=9B=BF=E6=8D=A2=E8=8D=89=E7=A8=BF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test_web/index.html | 58 ++++----------------------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/test_web/index.html b/test_web/index.html index f0b9b96..8ea46c5 100644 --- a/test_web/index.html +++ b/test_web/index.html @@ -4160,59 +4160,6 @@ ${transcript} return groups; } - function getLivePartialMatchView(text) { - const source = String(text || ""); - let normalized = ""; - const sourceOffsets = []; - - // Ignore punctuation while matching snapshots because partial ASR often revises it. - for (let offset = 0; offset < source.length;) { - const character = String.fromCodePoint(source.codePointAt(offset)); - if (!/[\s\p{P}\p{S}]/u.test(character)) { - normalized += character; - sourceOffsets.push(offset); - } - offset += character.length; - } - - return { normalized, sourceOffsets }; - } - - function mergeLivePartialSnapshot(currentText, nextText) { - const current = String(currentText || "").trim(); - const next = String(nextText || "").trim(); - if (!current) return next; - if (!next) return current; - - const currentView = getLivePartialMatchView(current); - const nextView = getLivePartialMatchView(next); - const currentNormalized = currentView.normalized; - const nextNormalized = nextView.normalized; - if (!currentNormalized || !nextNormalized) return next.startsWith(current) ? next : current; - - // FunASR's online model emits new chunks that its client appends. Qwen sends - // revisable rolling snapshots, so accept growth directly and merge their tail overlap. - if (nextNormalized.startsWith(currentNormalized)) return next; - if (currentNormalized.startsWith(nextNormalized)) return current; - - const maxOverlap = Math.min(currentNormalized.length, nextNormalized.length, 128); - for (let overlapLength = maxOverlap; overlapLength >= 2; overlapLength -= 1) { - const overlap = currentNormalized.slice(-overlapLength); - const nextMatchIndex = nextNormalized.lastIndexOf(overlap); - if (nextMatchIndex < 0) continue; - - const currentMatchIndex = currentNormalized.length - overlapLength; - const currentTextOffset = currentView.sourceOffsets[currentMatchIndex]; - const nextTextOffset = nextView.sourceOffsets[nextMatchIndex]; - return `${current.slice(0, currentTextOffset)}${next.slice(nextTextOffset)}`; - } - - // Without a textual overlap there is no safe way to distinguish new text from a rewrite. - // Keep the short startup hypothesis replaceable until the model has produced context. - if (currentNormalized.length <= 16) return next; - return current; - } - function renderLiveTranscript() { const items = groupLiveTranscriptItems(state.liveTranscript); if (!items.length) { @@ -4336,7 +4283,10 @@ ${transcript} if (existingPartialIndex >= 0) { const existingPartial = state.liveTranscript[existingPartialIndex]; existingPartial.label = label; - existingPartial.text = mergeLivePartialSnapshot(existingPartial.text, safeText); + // Backend partial events are complete, revisable snapshots for this segment. + // Replace the draft wholesale so a changed hypothesis cannot leave stale text + // frozen in the bubble; the matching final event replaces this same segment. + existingPartial.text = safeText; existingPartial.speaker = speaker; existingPartial.speakerPending = speakerPending; existingPartial.segmentIndex = segmentIndex;