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:
@@ -74,7 +74,7 @@ STT settings (all optional in `hello` and `config`):
|
||||
| `end_silence_ms` | 300 | Trailing VAD silence that ends an utterance. Range 100-2000. |
|
||||
| `final_beam` | 2 | Beam size for finals (partials always use 1). Range 1-5. |
|
||||
| `language` | `"ko"` | Whisper language code, or `null` to detect per utterance. |
|
||||
| `hotwords` | `[]` | Words (wake words, names) passed to Whisper as a hint. |
|
||||
| `hotwords` | `[]` | Words (wake words, names) passed to Whisper as a hint. The hint alone made Whisper write the wake word on laughter, so with hotwords every clip is also decoded without them and that plain decode decides (see Hallucination gate). |
|
||||
|
||||
### Utterance rules
|
||||
|
||||
@@ -82,10 +82,12 @@ Each speaker's audio is mixed to mono, resampled to 16 kHz with a streaming filt
|
||||
its own streaming Silero VAD (512-sample windows, state kept between frames).
|
||||
|
||||
- **Start**: the first window with speech probability at or above 0.5. The 200 ms before it are kept.
|
||||
- **speech_start** is sent once the utterance holds 250 ms of speech windows. An utterance that ends
|
||||
before that is dropped without any message (a click or a cough).
|
||||
- **speech_start** is sent once the utterance holds 250 ms of clearly voiced windows (probability at
|
||||
or above 0.5). An utterance that ends before that is dropped without any message and never reaches
|
||||
the model: a click, a cough, or noise.
|
||||
- **Speech continues** while windows stay at or above 0.35 (hysteresis); a quieter window counts as
|
||||
silence.
|
||||
silence. Windows between 0.35 and 0.5 keep an utterance open but are not evidence of a voice, so
|
||||
noise the VAD half-believes (fans, typing) never adds up to an utterance.
|
||||
- **End**, with `end_reason`:
|
||||
- `silence`: trailing silence reached `end_silence_ms`.
|
||||
- `speaking_end`: the app sent `speaking_end`. Discord stops sending packets when a user stops
|
||||
@@ -94,7 +96,12 @@ its own streaming Silero VAD (512-sample windows, state kept between frames).
|
||||
- `max_length`: the utterance reached 28 seconds (Whisper's window). The next audio starts a new
|
||||
utterance.
|
||||
- The final clip keeps at most 200 ms of trailing silence.
|
||||
- Before transcription the clip is peak-normalised to 0.9 with the gain capped at 10x.
|
||||
- **Loudness equalisation** before transcription (partials and finals), so a quiet and a loud speaker
|
||||
reach the model alike: rumble below 60 Hz is removed, the level is measured as the RMS of the voiced
|
||||
windows only (silence, a click or a knock do not set the gain), the clip is brought to -20 dBFS with
|
||||
the gain kept between -20 and +40 dB, and peaks above 0.8 are soft-limited below 0.98 instead of
|
||||
clipping. Measured: speech from -60 dBFS to clipped shouting was transcribed equally well, and quiet
|
||||
speech under loud clicks or knocks better than with peak normalisation.
|
||||
|
||||
### Scheduling
|
||||
|
||||
@@ -112,9 +119,35 @@ wait seconds behind it; two clips keep that wait to about one clip's time. With
|
||||
captions fall behind and only the newest audio per speaker is transcribed.
|
||||
|
||||
Batches are grouped by decode settings (beam, language, hotwords). A partial whose utterance has
|
||||
already ended, or that is older than the last partial sent, is dropped. Whisper output is rejected
|
||||
(empty text) when `no_speech_prob >= 0.5` or the confidence (`avg_logprob + 1`) is below 0.3, the
|
||||
same gate as v1.
|
||||
already ended, or that is older than the last partial sent, is dropped.
|
||||
|
||||
### Hallucination gate
|
||||
|
||||
Whisper writes text for voice-like sounds without words (coughs, laughter, a crying baby) and,
|
||||
prompted with a hint, the hint itself. A transcript is kept only when all of these hold, else the
|
||||
text is empty:
|
||||
|
||||
- It has letters or digits (not only punctuation).
|
||||
- Its mean log-probability per token is at least -0.7. This is the decoder's own per-token mean; the
|
||||
`avg_logprob` used by faster-whisper divides by one token more, which lifted a three-token
|
||||
hallucination from -0.73 to -0.55 and let it through.
|
||||
- Its compression ratio (UTF-8 bytes over zlib bytes) is at most 2.4, which catches repetition loops.
|
||||
- With hotwords: the clip is decoded once with them and once without, from the same encoder pass.
|
||||
The plain decode must pass the checks above, otherwise nothing was said. The hinted text is used
|
||||
only when it stays within half the plain text's letters of it and mentions every hotword as often
|
||||
as the plain one (a near miss in spelling counts as a mention), so the hint can fix how a spoken
|
||||
wake word is written but never add or drop one. Otherwise the plain text is used.
|
||||
|
||||
`no_speech_prob` is not used: large-v3-turbo reports 0.0 for silence and noise alike.
|
||||
|
||||
Measured (2026-11-11, RTX 5050) with 54 real noise recordings from ESC-50 (typing, mouse, breathing,
|
||||
coughing, laughing, crying, vacuum, ...), each at its own level and at -25 dBFS: of the 108 noise-only
|
||||
clips, 102 never reached the model (the VAD rule above) and the 6 that did (coughs, laughter, crying)
|
||||
all came out empty, with and without the wake word hint. Over 89 mixes of speech with that noise
|
||||
(SNR 20, 10 and 0 dB, plus clean) the mean character error rate was 4.8%. Left over: one
|
||||
"thank you" written for laughter just before a sentence (mean log-probability -0.70, right at the
|
||||
line), two short words lost in loud noise, and one word repeated three times at SNR 0. A stricter
|
||||
line (-0.6) would lose more real words than it saves.
|
||||
|
||||
### TTS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user