fix(voice_worker): the wake word hint may never add, drop or create a wake word
Hotword occurrences were counted with fuzzy matching, which never counted a one-letter wake word (so a hinted "봇 ..." was accepted over a plain decode without it) and counted the real word "서비스" as "자비스" (so the hint could turn it into the wake word). Occurrences are now counted exactly (case, spacing and punctuation ignored); near misses are left as heard for call detection. The real-noise eval now plays each recording as recorded and at -25 dBFS and reports how many clips reached the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -292,12 +292,13 @@ def test_quiet_and_loud_speakers_are_both_understood(engines, level_db):
|
||||
|
||||
def test_real_noise_recordings_produce_no_text(engines):
|
||||
"""Optional: point JARVIS_NOISE_DIR at noise-only recordings (16 kHz or 44.1 kHz mono/stereo WAV,
|
||||
e.g. ESC-50 keyboard, mouse, breathing, coughing, laughing). None may produce text."""
|
||||
e.g. ESC-50 keyboard, mouse, breathing, coughing, laughing; ESC-50 is CC BY-NC, so it is not in
|
||||
the repository). Each plays as recorded and at -25 dBFS; none may produce text."""
|
||||
folder = os.environ.get("JARVIS_NOISE_DIR")
|
||||
if not folder:
|
||||
pytest.skip("set JARVIS_NOISE_DIR to a folder of noise-only WAV files")
|
||||
from scipy.signal import resample_poly
|
||||
texts = []
|
||||
texts, reached, clips = [], 0, 0
|
||||
for path in sorted(Path(folder).glob("*.wav")):
|
||||
with wave.open(str(path), "rb") as w:
|
||||
x = np.frombuffer(w.readframes(w.getnframes()), dtype="<i2").astype(np.float32) / 32768.0
|
||||
@@ -308,8 +309,10 @@ def test_real_noise_recordings_produce_no_text(engines):
|
||||
from math import gcd
|
||||
g = gcd(rate, 16000)
|
||||
x = resample_poly(x, 16000 // g, rate // g).astype(np.float32)
|
||||
for m in _stream_clip_16k(engines, x, {"hotwords": ["자비스"], "partials": False}):
|
||||
if m["text"]:
|
||||
texts.append((path.name, m["text"]))
|
||||
print(texts)
|
||||
for level in (x, np.clip(_at_db(x, -25), -1, 1)): # as recorded, and as a loud mic would send it
|
||||
clips += 1
|
||||
finals = _stream_clip_16k(engines, level, {"hotwords": ["자비스"], "partials": False})
|
||||
reached += bool(finals) # a final means the clip passed the VAD and went to the model
|
||||
texts += [(path.name, m["text"]) for m in finals if m["text"]]
|
||||
print(f"noise clips {clips}, reached the model {reached}, with text {texts}")
|
||||
assert texts == []
|
||||
|
||||
Reference in New Issue
Block a user