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:
@@ -15,7 +15,7 @@ import numpy as np
|
||||
|
||||
from jarvis.debug import debug_log
|
||||
|
||||
from .audio import InputConverter
|
||||
from .audio import InputConverter, loudness_equalise
|
||||
from .protocol import KIND_AUDIO, ProtocolError, decode_audio_frame, encode_tts_frame
|
||||
from .scheduler import DecodeOptions, SttResult, SttScheduler, Transcriber
|
||||
from .segmenter import SR, Final, Partial, Segmenter, SpeechStart, VadStream
|
||||
@@ -211,7 +211,7 @@ class Session:
|
||||
self.send({"type": "speech_start", "speaker": speaker, "utt": ev.utt})
|
||||
elif isinstance(ev, Partial):
|
||||
if sched and self.settings.partials:
|
||||
sched.submit_partial((self.sid, speaker), ev.audio, self._opts(1),
|
||||
sched.submit_partial((self.sid, speaker), loudness_equalise(ev.audio, ev.voiced), self._opts(1),
|
||||
self._partial_cb(speaker, st, ev.utt))
|
||||
elif isinstance(ev, Final):
|
||||
debug_log(f"utterance end speaker={speaker} utt={ev.utt} reason={ev.reason} "
|
||||
@@ -219,7 +219,8 @@ class Session:
|
||||
if sched is None:
|
||||
self._send_final(speaker, ev, SttResult("", 0, "stt unavailable"))
|
||||
else:
|
||||
sched.submit_final((self.sid, speaker), ev.audio, self._opts(self.settings.final_beam),
|
||||
sched.submit_final((self.sid, speaker), loudness_equalise(ev.audio, ev.voiced),
|
||||
self._opts(self.settings.final_beam),
|
||||
lambda res, ev=ev: self._send_final(speaker, ev, res))
|
||||
|
||||
def _partial_cb(self, speaker: str, st: _Speaker, utt: int):
|
||||
|
||||
Reference in New Issue
Block a user