From b927b2c2746efaf7f91d03cec1c123a3d52bf62b Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 29 Sep 2026 10:54:22 +0800 Subject: fix(vad): bundle local Silero model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [问题原因] - 先前实现会在包内权重缺失时读取外部 faster-whisper 资源,无法满足自包含部署要求。 [问题根因] - 项目包中尚未包含已验证的 ONNX 权重,VAD 路径保留了开发期回退逻辑。 [修复方案] - 提交已校验 SHA-256 的本地 Silero ONNX 权重并移除外部包回退。 - 增加模型打包和缺失模型失败路径测试,并更新来源、MIT 许可和哈希说明。 [影响范围] - VAD 现在只加载项目包内模型,不联网且不依赖 faster-whisper 运行时资源。 - 未安装、启用或启动任何用户 systemd 服务。 --- tests/test_vad.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/test_vad.py') 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() -- cgit v1.2.3