Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion funasr/bin/realtime_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,8 @@ def _reconcile_completed_segment_text(self, decoded_text, seg, decode_succeeded)
and recent_eligible
and recent_observations >= 2
and int(recent_start_ms) == int(seg[0])
and 0 <= tail_gap_ms <= max(100, decode_chunk_ms * 2)
and -max(100, decode_chunk_ms) <= tail_gap_ms
and tail_gap_ms <= max(100, decode_chunk_ms * 2)
and recent_partial
and not recent_hallucinated
):
Expand Down
42 changes: 42 additions & 0 deletions tests/test_realtime_ws_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,48 @@ def test_long_segment_recovers_from_single_character_final():
assert text == partial


def test_long_segment_accepts_partial_slightly_past_vad_end():
module = load_service_module()
partial = (
"哎,不好意思,上午好,高雄交通比较混乱,影响人有点。"
"哎,哎,胡总,各位长官,大家好。"
)
session = make_reported_long_segment_reconciliation_session(
module, partial, partial_end_ms=126976
)
session.last_partial_start_ms = 114430
session.segment_best_partial_start_ms = 114430

text = session._reconcile_completed_segment_text(
"哎",
[114430, 126740],
decode_succeeded=True,
)

assert text == partial


def test_long_segment_rejects_partial_far_past_vad_end():
module = load_service_module()
partial = (
"哎,不好意思,上午好,高雄交通比较混乱,影响人有点。"
"哎,哎,胡总,各位长官,大家好。"
)
session = make_reported_long_segment_reconciliation_session(
module, partial, partial_end_ms=128800
)
session.last_partial_start_ms = 114430
session.segment_best_partial_start_ms = 114430

text = session._reconcile_completed_segment_text(
"哎",
[114430, 126740],
decode_succeeded=True,
)

assert text == "哎"


def test_long_segment_recovers_when_an_early_partial_correction_hides_tail_regression():
module = load_service_module()
partial = (
Expand Down