[Bugfix] Tolerate a bounded TTS tail in the audio-text similarity gate (#7358)
Signed-off-by: tly <2200895168@qq.com>
This commit is contained in:
1 parent
c197cd2422
commit
2185c4e26f
2 files changed
+89
-1
No files matched your search
@@ -126,3 +126,50 @@ def test_escalated_transcript_keeps_declared_language(monkeypatch):
|
||||
|
||||
assert captured["model_size"] == "large-v3"
|
||||
assert captured["language"] == "en"
|
||||
|
||||
|
||||
def test_bounded_tail_after_complete_answer_passes():
|
||||
# The exact shape from the #6815 nightly failure: the full answer is spoken
|
||||
# verbatim, then a two-word unrelated tail trips the cosine gate.
|
||||
assert assertions._transcript_has_bounded_tail(
|
||||
"The squares in this image are black. nack shit.",
|
||||
"The squares in this image are black.",
|
||||
)
|
||||
|
||||
|
||||
def test_bounded_tail_exact_match_passes():
|
||||
assert assertions._transcript_has_bounded_tail(
|
||||
"The squares in this image are black.",
|
||||
"The squares in this image are black.",
|
||||
)
|
||||
|
||||
|
||||
def test_bounded_tail_rejects_different_content():
|
||||
assert not assertions._transcript_has_bounded_tail(
|
||||
"The circles in this picture are black and white.",
|
||||
"The squares in this image are black.",
|
||||
)
|
||||
|
||||
|
||||
def test_bounded_tail_rejects_long_tail():
|
||||
# Eight expected words allow at most max(2, ceil(0.2 * 8)) = 2 tail words.
|
||||
assert not assertions._transcript_has_bounded_tail(
|
||||
"The squares in this image are black and some extra words follow here",
|
||||
"The squares in this image are black.",
|
||||
)
|
||||
|
||||
|
||||
def test_bounded_tail_rejects_word_boundary_split():
|
||||
assert not assertions._transcript_has_bounded_tail(
|
||||
"The squares in this image are blacks.",
|
||||
"The squares in this image are black.",
|
||||
)
|
||||
|
||||
|
||||
def test_bounded_tail_allows_ratio_bound_for_long_answers():
|
||||
expected = " ".join(["word"] * 20)
|
||||
four_word_tail = expected + " one two three four"
|
||||
five_word_tail = expected + " one two three four five"
|
||||
# Twenty expected words allow up to max(2, ceil(0.2 * 20)) = 4 tail words.
|
||||
assert assertions._transcript_has_bounded_tail(four_word_tail, expected)
|
||||
assert not assertions._transcript_has_bounded_tail(five_word_tail, expected)
|
||||
Reference in new issue
Block a user