mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
fix(sensevoice): keep words separate at standalone boundaries
Signed-off-by: LauraGPT <[email protected]>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user