Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
fix(cli): repack tiny-gap subtitle boundaries
LauraGPTdb959d301031
diff --git a/funasr/cli.py b/funasr/cli.pyindex 6a58d27bd..d845d88b7 100644--- a/funasr/cli.py+++ b/funasr/cli.py@@ -80,6 +80,7 @@ def merge_subtitle_segments("""Group sentence timestamps into bounded, readable subtitle cues."""def can_follow(left, right):left_text = str(left.get("text", ""))+ right_text = str(right.get("text", ""))gap_ms = right.get("start", 0) - left.get("end", 0)left_speaker = left.get("speaker", left.get("spk"))right_speaker = right.get("speaker", right.get("spk"))@@ -89,6 +90,13 @@ def merge_subtitle_segments(and (left_text.rstrip().endswith(SUBTITLE_CONTINUATION_PUNCTUATION)or _subtitle_body_length(left_text) <= 2+ or (+ gap_ms <= min(max_gap_ms, 100)+ and _subtitle_body_length(right_text) > 2+ and right_text.rstrip().endswith(+ SUBTITLE_CONTINUATION_PUNCTUATION+ )+ )))diff --git a/tests/test_cli.py b/tests/test_cli.pyindex db9ab38e8..dafbd25cf 100644--- a/tests/test_cli.py+++ b/tests/test_cli.py@@ -238,6 +238,41 @@ def test_merge_subtitle_segments_keeps_continuation_chain_with_its_ending():]+def test_merge_subtitle_segments_repacks_false_sentence_boundary_after_tiny_gap():+ segments = [+ {"start": 148930, "end": 149830, "text": "就在八月二十五日,"},+ {+ "start": 150010,+ "end": 151930,+ "text": "上汽大通直接向平台发起投诉,",+ },+ {+ "start": 152170,+ "end": 153970,+ "text": "投诉对象是那些转述基金会。",+ },+ {"start": 154030, "end": 155050, "text": "声明的自媒体文章,"},+ {+ "start": 155470,+ "end": 157330,+ "text": "上汽大通的投诉内容写的很清楚,",+ },+ ]++ assert cli.merge_subtitle_segments(segments) == [+ {+ "start": 148930,+ "end": 151930,+ "text": "就在八月二十五日,上汽大通直接向平台发起投诉,",+ },+ {+ "start": 152170,+ "end": 157330,+ "text": "投诉对象是那些转述基金会。声明的自媒体文章,上汽大通的投诉内容写的很清楚,",+ },+ ]++def test_merge_subtitle_segments_groups_two_character_sentence():segments = [{"start": 12450, "end": 12690, "text": "突然。"},