diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | THIRD_PARTY_NOTICES.md | 14 | ||||
| -rw-r--r-- | src/mic_clipper/assets/silero_vad_v6.onnx | bin | 0 -> 1245151 bytes | |||
| -rw-r--r-- | src/mic_clipper/vad.py | 13 | ||||
| -rw-r--r-- | tests/test_vad.py | 17 |
5 files changed, 30 insertions, 16 deletions
@@ -30,7 +30,7 @@ src/mic_clipper/assets/silero_vad_v6.onnx ``` -该权重应从当前机器已验证的 `faster-whisper` 1.2.1 本地资源复制而来,归属和 MIT 许可说明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。当前开发代码为便于本机测试会回退读取该已预置的本地资源;它不会下载模型。该回退不是自包含部署方案,审阅/部署前必须把权重复制进项目包。 +该权重已从当前机器已验证的 `faster-whisper` 1.2.1 本地资源复制进项目包。归属、MIT 许可声明和 SHA-256 校验值见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。运行时代码只读取包内模型;不会下载模型,也不会回退读取外部包资源。 ## 安装与服务 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index e38fc8e..e147b4e 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -2,12 +2,14 @@ ## Silero VAD ONNX weight -The intended bundled file is `src/mic_clipper/assets/silero_vad_v6.onnx`. +The bundled file is `src/mic_clipper/assets/silero_vad_v6.onnx`. -Its local source is the `assets/silero_vad_v6.onnx` file in the verified -`faster-whisper` 1.2.1 installation. That package's installed metadata declares -the MIT license and its VAD implementation attributes the model integration to +It was copied from `assets/silero_vad_v6.onnx` in the locally verified +`faster-whisper` 1.2.1 installation. Both files have SHA-256 +`4cbf549b8326f60f80f2536d9eefeb450a9abe83365a098031c89719f1be17d2`. +The installed package metadata declares the MIT license, and its VAD +implementation attributes the model integration to [`snakers4/silero-vad`](https://github.com/snakers4/silero-vad). -The ONNX weight has no network retrieval path in this project. The asset must be -present before deployment; it is intentionally not downloaded at runtime. +The ONNX weight is bundled and has no network retrieval path. The application +never downloads models at runtime. diff --git a/src/mic_clipper/assets/silero_vad_v6.onnx b/src/mic_clipper/assets/silero_vad_v6.onnx Binary files differnew file mode 100644 index 0000000..9febab9 --- /dev/null +++ b/src/mic_clipper/assets/silero_vad_v6.onnx diff --git a/src/mic_clipper/vad.py b/src/mic_clipper/vad.py index 705dfd8..e82d15a 100644 --- a/src/mic_clipper/vad.py +++ b/src/mic_clipper/vad.py @@ -47,13 +47,8 @@ class SileroVad: @staticmethod def _default_model_path() -> Path: bundled = resources.files("mic_clipper.assets").joinpath("silero_vad_v6.onnx") - if bundled.is_file(): - return Path(bundled) - try: - import faster_whisper - except ImportError as error: + if not bundled.is_file(): raise RuntimeError( - "Silero VAD model is missing; bundle silero_vad_v6.onnx or install the " - "pre-provisioned faster-whisper runtime asset" - ) from error - return Path(faster_whisper.__file__).parent / "assets" / "silero_vad_v6.onnx" + "packaged Silero VAD model is missing: silero_vad_v6.onnx" + ) + return Path(bundled) 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() |
