Verify VAD allocation limits and decoder overshoot contracts

This commit is contained in:
karl committed 2026-10-13 13:44:06 +02:00
1 parent 7a6ab9fc6a
commit f827df11c6
2 files changed
+32

No files matched your search

+6
View File
@@ -211,6 +211,12 @@ was scored. All three native contracts passed again with the corrected build;
four mapping regressions cover centiseconds, source origin, padded tails and four mapping regressions cover centiseconds, source origin, padded tails and
invalid intervals. Segmentation parameters and model remained frozen. invalid intervals. Segmentation parameters and model remained frozen.
The expanded native contract suite then passed six tests in 0.471 seconds:
missing-model failures emit no report, oversized PCM is rejected before model
loading, and finite decoder overshoot is accepted by actual CPU inference
without input clipping. The synthetic DC overshoot input tests the input
contract only and is not included in the media quality pool.
This small VAD-only result supports testing gated ASR next. It does not establish This small VAD-only result supports testing gated ASR next. It does not establish
speech recall, transcript correctness, timestamp accuracy, retrieval improvement speech recall, transcript correctness, timestamp accuracy, retrieval improvement
or a general music policy. No production gate was added and original Google or a general music policy. No production gate was added and original Google
+26
View File
@@ -48,6 +48,32 @@ class NativeContract(unittest.TestCase):
self.assertEqual(result.returncode, 2) self.assertEqual(result.returncode, 2)
self.assertEqual(result.stdout, b"") self.assertEqual(result.stdout, b"")
def test_missing_model_is_failure_without_report(self):
with tempfile.TemporaryDirectory(prefix="searchi-vad-missing-") as scratch:
pcm = Path(scratch) / "silence.f32"
pcm.write_bytes(b"\0" * 64000)
result = subprocess.run([str(self.worker), str(Path(scratch) / "missing.bin"), str(pcm)],
capture_output=True, timeout=5)
self.assertEqual(result.returncode, 3)
self.assertEqual(result.stdout, b"")
def test_oversized_pcm_rejected_before_model_loading(self):
with tempfile.TemporaryDirectory(prefix="searchi-vad-large-") as scratch:
pcm = Path(scratch) / "oversized.f32"
with pcm.open("wb") as stream:
stream.truncate(16000 * 600 * 4 + 4)
result = subprocess.run([str(self.worker), "missing.bin", str(pcm)],
capture_output=True, timeout=5)
self.assertEqual(result.returncode, 2)
self.assertEqual(result.stdout, b"")
def test_finite_decoder_overshoot_is_preserved(self):
# A DC input is not speech evidence. This checks only the input contract:
# valid floating-point decoder output must not be clipped or rejected.
result = self.run_pcm(struct.pack("<f", 1.01) * 16000)
self.assertEqual(result.returncode, 0, result.stderr.decode("utf-8", errors="replace"))
self.assertEqual(json.loads(result.stdout)["samples"], 16000)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()