summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_vad.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_vad.py b/tests/test_vad.py
index 98826ae..f2e3d65 100644
--- a/tests/test_vad.py
+++ b/tests/test_vad.py
@@ -1,6 +1,8 @@
import numpy as np
import pytest
+from importlib import resources
+import mic_clipper.vad as vad_module
from mic_clipper.vad import FRAME_SAMPLES, SileroVad
@@ -12,6 +14,21 @@ def test_bundled_silero_vad_accepts_512_samples_and_returns_probability():
assert 0.0 <= probability <= 1.0
+def test_silero_weight_is_packaged_with_the_application():
+ model_path = resources.files("mic_clipper.assets").joinpath("silero_vad_v6.onnx")
+
+ assert model_path.is_file()
+
+
+def test_missing_packaged_weight_does_not_fall_back_to_an_external_package(
+ monkeypatch, tmp_path
+):
+ monkeypatch.setattr(vad_module.resources, "files", lambda _package: tmp_path)
+
+ with pytest.raises(RuntimeError, match="packaged Silero VAD model is missing"):
+ SileroVad._default_model_path()
+
+
def test_bundled_silero_vad_rejects_non_512_sample_frames():
vad = SileroVad()