mirror of
https://github.com/pyannote/pyannote-audio.git
synced 2026-11-20 13:07:51 +09:00
* feat(cli): add --subfolder option to benchmark command (#2063) * fix(utils): fix `SpeakerDiarizationMixin.optimal_mapping` when `reference` is a mapping * fix(task): fix `balance` option crashing training with `KeyError: 'metadata'` (#2067) * fix(io): fix `Audio.crop` raising when an in-memory waveform is cropped up to its very end (#2068) * fix(model): make Model.default_activation return identity for unsupported tasks * fix: compute sample duration from preloaded waveform * fix(pipeline): omit unset runtime options from model references (#2080) Co-authored-by: abeeranajam31 <128603901+abeeranajam31@users.noreply.github.com> Co-authored-by: antoinelaurent <antoinelaurent@me.com> Co-authored-by: Kayvan Zahiri <123409429+Kayvan-Zahiri@users.noreply.github.com> Co-authored-by: Mohammad Hijjawi <51020382+MohammadHijjawi97@users.noreply.github.com>
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
# Copyright (c) 2025- pyannoteAI
|
|
|
|
import multiprocessing
|
|
import sys
|
|
import warnings
|
|
|
|
import pytest
|
|
from pyannote.database import FileFinder, registry
|
|
|
|
from pyannote.audio.tasks import VoiceActivityDetection
|
|
|
|
|
|
@pytest.mark.parametrize("start_method", ["fork", "spawn", "forkserver", None])
|
|
@pytest.mark.parametrize("requested_workers", [0, 2, None])
|
|
def test_worker_start_method(monkeypatch, start_method, requested_workers):
|
|
monkeypatch.setattr(sys, "platform", "linux")
|
|
monkeypatch.setattr(
|
|
multiprocessing, "get_start_method", lambda allow_none: start_method
|
|
)
|
|
monkeypatch.setattr(
|
|
multiprocessing,
|
|
"get_all_start_methods",
|
|
lambda: ["forkserver", "fork", "spawn"],
|
|
)
|
|
monkeypatch.setattr(multiprocessing, "cpu_count", lambda: 4)
|
|
protocol = registry.get_protocol(
|
|
"Debug.SpeakerDiarization.Debug", preprocessors={"audio": FileFinder()}
|
|
)
|
|
fallback = requested_workers != 0 and start_method != "fork"
|
|
with warnings.catch_warnings(record=True) as caught:
|
|
task = VoiceActivityDetection(protocol, num_workers=requested_workers)
|
|
if fallback:
|
|
assert task.num_workers == 0
|
|
assert any("cannot be pickled" in str(w.message) for w in caught)
|
|
else:
|
|
assert task.num_workers == (
|
|
2 if requested_workers is None else requested_workers
|
|
)
|
|
assert not any("cannot be pickled" in str(w.message) for w in caught)
|