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:
@@ -33,6 +33,7 @@ class SpeechStart:
|
||||
class Partial:
|
||||
utt: int
|
||||
audio: np.ndarray
|
||||
voiced: np.ndarray # one bool per 512-sample window: the VAD heard speech there
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -41,6 +42,7 @@ class Final:
|
||||
audio: np.ndarray
|
||||
reason: str # silence | speaking_end | idle | max_length
|
||||
decided_at: float
|
||||
voiced: np.ndarray
|
||||
|
||||
|
||||
def _windows(ms: float) -> int:
|
||||
@@ -60,7 +62,8 @@ class Segmenter:
|
||||
def _reset(self) -> None:
|
||||
self._active = False
|
||||
self._win: list[np.ndarray] = []
|
||||
self._speech = 0
|
||||
self._voiced: list[bool] = []
|
||||
self._speech = 0 # windows that clearly held speech (>= START_PROB)
|
||||
self._trailing = 0
|
||||
self._started = False
|
||||
self._last_partial_at = 0.0
|
||||
@@ -83,7 +86,7 @@ class Segmenter:
|
||||
and now - self._last_partial_at >= self.settings.partial_interval_ms / 1000:
|
||||
self._last_partial_at = now
|
||||
self._last_partial_len = len(self._win)
|
||||
events.append(Partial(self._utt_count, np.concatenate(self._win)))
|
||||
events.append(Partial(self._utt_count, np.concatenate(self._win), np.array(self._voiced)))
|
||||
return events
|
||||
|
||||
def _window(self, w: np.ndarray, now: float) -> list:
|
||||
@@ -92,6 +95,7 @@ class Segmenter:
|
||||
if p >= START_PROB:
|
||||
self._active = True
|
||||
self._win = self._pre + [w]
|
||||
self._voiced = [False] * len(self._pre) + [True]
|
||||
self._pre = []
|
||||
self._speech = 1
|
||||
self._trailing = 0
|
||||
@@ -100,8 +104,12 @@ class Segmenter:
|
||||
del self._pre[:-_windows(PRE_ROLL_MS)]
|
||||
return []
|
||||
self._win.append(w)
|
||||
if p >= KEEP_PROB:
|
||||
self._voiced.append(p >= START_PROB)
|
||||
# "Maybe speech" (between the two thresholds) keeps an utterance going but is not evidence
|
||||
# of a voice, so noise the VAD half-believes never adds up to a call to the model.
|
||||
if p >= START_PROB:
|
||||
self._speech += 1
|
||||
if p >= KEEP_PROB:
|
||||
self._trailing = 0
|
||||
else:
|
||||
self._trailing += 1
|
||||
@@ -121,8 +129,9 @@ class Segmenter:
|
||||
events: list = []
|
||||
if self._active and self._started:
|
||||
drop = max(0, self._trailing - _windows(TAIL_KEEP_MS))
|
||||
kept = self._win[:len(self._win) - drop]
|
||||
events.append(Final(self._utt_count, np.concatenate(kept), reason, now))
|
||||
keep = len(self._win) - drop
|
||||
events.append(Final(self._utt_count, np.concatenate(self._win[:keep]), reason, now,
|
||||
np.array(self._voiced[:keep])))
|
||||
self._reset()
|
||||
return events
|
||||
|
||||
|
||||
Reference in New Issue
Block a user