From 3f2f34deeba9a634534838f554469f67784f9530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20BREDIN?= Date: Wed, 22 Oct 2025 18:21:44 +0200 Subject: [PATCH] chore: remove speechbrain and fix io unit tests (#1938) --- pyproject.toml | 2 +- tests/io_test.py | 7 ++++--- tests/test_speechbrain.py | 20 -------------------- 3 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 tests/test_speechbrain.py diff --git a/pyproject.toml b/pyproject.toml index 39087f04..5c6e429c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dependencies = [ pyannote-audio = "pyannote.audio.__main__:app" [project.optional-dependencies] -test = ["papermill>=2.6.0", "pytest>=8.3.4", "speechbrain>=1.0.2"] +test = ["papermill>=2.6.0", "pytest>=8.3.4"] doc = ["sphinx-rtd-theme>=3.0.2", "sphinx>=8.1.3"] cli = ["typer>=0.15.1"] separation = ["asteroid>=0.5.2", "transformers>=4.48.3"] diff --git a/tests/io_test.py b/tests/io_test.py index 4a582b79..3c542bef 100644 --- a/tests/io_test.py +++ b/tests/io_test.py @@ -1,5 +1,6 @@ import torch -import torchaudio +from torchcodec.decoders import AudioDecoder, AudioStreamMetadata + from pyannote.core import Segment from torch import Tensor @@ -9,8 +10,8 @@ from pyannote.audio.core.io import Audio def test_audio_resample(): "Audio is correctly resampled when it isn't the correct sample rate" test_file = "tests/data/dev00.wav" - info = torchaudio.info(test_file) - old_sr = info.sample_rate + metadata: AudioStreamMetadata = AudioDecoder(test_file).metadata + old_sr = metadata.sample_rate loader = Audio(sample_rate=old_sr // 2, mono="downmix") wav, sr = loader(test_file) assert isinstance(wav, Tensor) diff --git a/tests/test_speechbrain.py b/tests/test_speechbrain.py deleted file mode 100644 index 0ac9b60c..00000000 --- a/tests/test_speechbrain.py +++ /dev/null @@ -1,20 +0,0 @@ -import tempfile -import pytest -from speechbrain.inference import EncoderClassifier - - -@pytest.fixture() -def cache(): - return tempfile.mkdtemp() - -def test_import_speechbrain_encoder_classifier(cache): - """This is a simple test that check if speechbrain - EncoderClassifier can be imported. It does not check - if the model is working properly. - """ - - model = EncoderClassifier.from_hparams( - source="speechbrain/spkrec-ecapa-voxceleb", - savedir=cache, - ) - assert isinstance(model, EncoderClassifier)