fix(sensevoice): keep words separate at standalone boundaries

Signed-off-by: LauraGPT <[email protected]>
This commit is contained in:
LauraGPT
2026-09-29 06:12:59 +00:00
parent 2ddabb2c91
commit a57cc3f92a
2 changed files with 19 additions and 0 deletions
+1
View File
@@ -1093,6 +1093,7 @@ class SenseVoiceSmall(nn.Module):
start = int(start * 1000)
end = int(end * 1000)
if word == "▁":
prev_word = None
continue
if i == 0:
word = word[1:] if word.startswith("▁") else word
+18
View File
@@ -66,6 +66,24 @@ from funasr.models.sense_voice.model import SenseVoiceSmall
pytest.param(
["A", "\u2581B", "C"], ["A", "BC"], [[0, 125], [125, 375]], id="word-boundary"
),
pytest.param(
["Hello", "\u2581", "world"],
["Hello", "world"],
[[0, 125], [250, 375]],
id="standalone-word-boundary",
),
pytest.param(
["\u2581Hel", "lo", "\u2581", "wor", "ld"],
["Hello", "world"],
[[0, 250], [375, 625]],
id="subpieces-around-standalone-boundary",
),
pytest.param(
["Hello", "\u2581", "\u2581", "world"],
["Hello", "world"],
[[0, 125], [375, 500]],
id="repeated-standalone-boundaries",
),
],
)
def test_post_preserves_word_boundaries_and_timestamp_alignment(tokens, words, timestamps):