diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0e3b485 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,37 @@ +name: Test Package + +on: + workflow_dispatch: # запуск вручную + push: + branches: + - adamnsandle # или любая тестовая ветка + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: [3.8,3.9,3.10,3.11,3.12,3.13,3.14,3.15] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatchling pytest + + - name: Build package + run: python -m build --wheel --outdir dist + + - name: Install package + run: pip install dist/*.whl + + - name: Run tests + run: pytest tests \ No newline at end of file diff --git a/tests/data/test.mp3 b/tests/data/test.mp3 new file mode 100644 index 0000000..a9e8b51 Binary files /dev/null and b/tests/data/test.mp3 differ diff --git a/tests/data/test.opus b/tests/data/test.opus new file mode 100644 index 0000000..b7588a4 Binary files /dev/null and b/tests/data/test.opus differ diff --git a/tests/data/test.wav b/tests/data/test.wav new file mode 100644 index 0000000..0b1b64e Binary files /dev/null and b/tests/data/test.wav differ diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..85ecbcc --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,22 @@ +from silero_vad import load_silero_vad, read_audio, get_speech_timestamps +import torch +torch.set_num_threads(1) + +def test_jit_model(): + model = load_silero_vad(onnx=False) + for path in ["tests/data/test.wav", "tests/data/test.opus", "tests/data/test.mp3"]: + audio = read_audio(path, sampling_rate=16000) + speech_timestamps = get_speech_timestamps(audio, model, visualize_probs=False, return_seconds=True) + assert speech_timestamps is not None + out = model.audio_forward(audio, sr=16000) + assert out is not None + +def test_onnx_model(): + model = load_silero_vad(onnx=True) + for path in ["tests/data/test.wav", "tests/data/test.opus", "tests/data/test.mp3"]: + audio = read_audio(path, sampling_rate=16000) + speech_timestamps = get_speech_timestamps(audio, model, visualize_probs=False, return_seconds=True) + assert speech_timestamps is not None + + out = model.audio_forward(audio, sr=16000) + assert out is not None