优化过程中气泡内文字内容抖动问题
parent
5a02302587
commit
9a81e6ea55
|
|
@ -2079,20 +2079,31 @@ class Qwen3ASRService:
|
|||
*,
|
||||
native_stream_snapshot: bool = False,
|
||||
) -> str:
|
||||
"""Publish a growing preview while leaving Qwen's revisable tail for finalization."""
|
||||
"""Keep the visible prefix steady while allowing only a short native tail to revise."""
|
||||
previous = ctx.partial_preview_text
|
||||
if native_stream_snapshot:
|
||||
# Native Qwen text is a rolling snapshot. Exposing its unstable tail
|
||||
# can make the next correction fail the append-only check and freeze
|
||||
# the bubble at its first preview. Only publish the confirmed prefix.
|
||||
candidate = ctx.stable_partial_prefix.strip()
|
||||
# Qwen returns replaceable snapshots. Preserve everything before the
|
||||
# small mutable tail so a temporary short snapshot cannot shrink the bubble.
|
||||
candidate_text = self._sanitize_candidate_text(text)
|
||||
stable_prefix = ctx.stable_partial_prefix.strip()
|
||||
tail_chars = max(int(settings.REALTIME_STREAM_STABLE_TAIL_CHARS), 2)
|
||||
if stable_prefix and candidate_text.startswith(stable_prefix):
|
||||
suffix = candidate_text[len(stable_prefix):]
|
||||
candidate = stable_prefix + suffix[-tail_chars:]
|
||||
else:
|
||||
# Before a stable prefix exists, keep the first preview intact; later
|
||||
# updates may revise only its last tail_chars characters.
|
||||
candidate = candidate_text
|
||||
|
||||
immutable_prefix = previous[:-tail_chars] if len(previous) > tail_chars else ""
|
||||
if candidate and (not immutable_prefix or candidate.startswith(immutable_prefix)):
|
||||
ctx.partial_preview_text = candidate
|
||||
else:
|
||||
candidate = self._partial_display_text(ctx, text)
|
||||
if candidate and (not previous or candidate.startswith(previous)):
|
||||
ctx.partial_preview_text = candidate
|
||||
|
||||
previous = ctx.partial_preview_text
|
||||
if candidate and (not previous or candidate.startswith(previous)):
|
||||
ctx.partial_preview_text = candidate
|
||||
# If Qwen revises already published text, keep the preview fixed. The
|
||||
# final segment event will replace it with the model's finalized result.
|
||||
# Revisions outside the mutable tail stay frozen until the final segment arrives.
|
||||
return ctx.partial_preview_text
|
||||
|
||||
def _is_suspicious_segment_text(
|
||||
|
|
@ -3139,18 +3150,11 @@ class Qwen3ASRService:
|
|||
ctx,
|
||||
visible_observed,
|
||||
)
|
||||
if has_native_stream_snapshot:
|
||||
# 灰色待确认气泡用于展示 Qwen 当前快照,允许它随模型修正;
|
||||
# final 候选仍使用上面的稳定文本,避免演示预览影响定稿。
|
||||
partial_display = self._trim_previous_segment_overlap(
|
||||
ctx,
|
||||
current,
|
||||
)
|
||||
else:
|
||||
partial_display = self._append_only_partial_preview(
|
||||
ctx,
|
||||
visible_observed,
|
||||
)
|
||||
partial_display = self._append_only_partial_preview(
|
||||
ctx,
|
||||
visible_observed,
|
||||
native_stream_snapshot=has_native_stream_snapshot,
|
||||
)
|
||||
partial_display = self._clip_partial_text(partial_display, ctx)
|
||||
if (
|
||||
partial_display
|
||||
|
|
|
|||
Loading…
Reference in New Issue