perf(voice): anchor ASR alignment on unique trigrams

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5.5 committed 2026-10-20 08:46:30 +02:00
1 parent f958780c67
commit c14160f81c
2 files changed
+70 -5

No files matched your search

+11
View File
@@ -172,3 +172,14 @@ def test_map_speeches_pairs_ensemble_ids_in_sequence():
assert map_speeches(source, targets, ensembles) == {0: 0, 1: 1, 2: 2}
# an individual never stands in for an ensemble
assert map_speeches([sp("faust", 10)], [Target(0, "citizens", 10, "x")], ensembles) == {}
def test_match_tokens_anchors_and_fills():
from vnpipe.voice_align import match_tokens
a = ["und", "die", "der", "ein", "wort", "a", "b", "c", "d", "e", "f", "g", "x", "y", "z"]
b = ["und", "die", "ein", "wort", "a", "b", "c", "d", "e", "f", "g", "q", "y", "z"]
pairs = match_tokens(a, b)
assert all(a[i] == b[j] for i, j in pairs)
assert [i for i, _ in pairs] == sorted(i for i, _ in pairs)
assert len(pairs) >= 12