fix(voice_worker): even out speaker loudness and stop transcribing noise into words

- Loudness equalisation replaces peak normalisation: rumble below 60 Hz removed, level measured on
  the VAD-voiced windows only, brought to -20 dBFS (gain -20..+40 dB), soft limiter below 0.98.
- Only clearly voiced windows (VAD >= 0.5) count towards the 250 ms needed before an utterance
  reaches the model, so noise the VAD half-believes never calls Whisper.
- Hallucination gate: mean token log-probability >= -0.7 (the old len/(len+1) correction let short
  hallucinations through), compression ratio <= 2.4; no_speech_prob dropped (always 0.0 on turbo).
- With hotwords, the plain decode of the same encoder pass decides; the hint may fix a wake word's
  spelling but cannot add or drop one (it wrote the wake word on laughter and after real sentences).
- Opt-in real-model evals: voice-like babble with the hint, speech over babble, quiet and clipped
  speakers, and a JARVIS_NOISE_DIR folder of real noise recordings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-11 10:27:38 +09:00
parent a7685e9078
commit 590cd07268
11 changed files with 460 additions and 54 deletions

View File

@@ -102,6 +102,30 @@ def test_hysteresis_keeps_speech_going_but_never_starts_it():
assert len(f.of(Final)) == 1
@pytest.mark.unit
def test_weak_speech_like_noise_never_builds_up_to_an_utterance():
"""A breath of real speech probability followed by a long stretch of 'maybe speech' (fans,
keyboard, background rumble that the VAD scores around 0.4) is not enough to call the model."""
f = Feeder()
for _ in range(3):
f.feed(0.9, 40)
f.feed(0.4, 1000)
f.feed(0.0, 500)
assert f.events == []
@pytest.mark.unit
def test_finals_mark_which_windows_were_voiced():
f = Feeder()
f.feed(0.0, 500)
f.feed(0.9, 640)
f.feed(0.0, 500)
fin = f.of(Final)[0]
assert len(fin.voiced) == -(-len(fin.audio) // 512)
assert 20 <= fin.voiced.sum() <= 21 # 640 ms of 32 ms windows, not aligned to the frames
assert not fin.voiced[0] and not fin.voiced[-1] # pre-roll and tail are not voiced
@pytest.mark.unit
def test_speaking_end_closes_the_utterance_at_once():
f = Feeder()