Correct the voice_gate_ratio tuning direction

A higher ratio raises the loudness gate, so it rejects more audio rather than less. The config guidance claimed the opposite; pin the direction with a test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
JavisandCopilot committed 2026-10-10 13:07:32 +02:00
1 parent 1fa75e58fc
commit 4c16f87a3e
3 files changed
+22 -3

No files matched your search

+16
View File
@@ -129,6 +129,22 @@ class SpeechEndpointerTests(unittest.TestCase):
self.assertAlmostEqual(ep.background, before)
self.assertFalse(ep.process(frame(MUSIC_RMS * 2.0)).is_speech)
def test_a_higher_ratio_is_stricter(self) -> None:
"""Pins the documented tuning direction.
Raising the ratio rejects more audio (so it can clip quiet commands);
lowering it admits more (so playback can keep the recorder running).
"""
def accepts(ratio: float) -> bool:
ep = endpointer(ratio=ratio)
for _ in range(50):
ep.observe(frame(MUSIC_RMS))
ep.reset()
return ep.process(frame(MUSIC_RMS * 2.5)).is_speech
self.assertTrue(accepts(2.0)) # permissive — the frame counts as the user
self.assertFalse(accepts(4.0)) # strict — the same frame is rejected
def test_ratio_zero_disables_the_gate(self) -> None:
ep = endpointer(ratio=0.0)
self.assertFalse(ep.enabled)