From 8fd60cc51e23f6d5e1e7fcfe75fdffc6812eccdc Mon Sep 17 00:00:00 2001 From: Eduardo Pacheco Date: Tue, 22 Sep 2026 16:18:06 -0300 Subject: [PATCH] SpeakerKit: pass --diarizer instead of --engine to speakerkitpro-cli speakerkitpro-cli `diarize` selects the backend with `--diarizer pyannote|sortformer`; the `--engine` flag openbench sent is rejected with "Unknown option '--engine'", so every `speakerkit*` evaluation against a current argmax-sdk-swift build failed on the first sample. Add unit tests for the generated CLI arguments. Co-Authored-By: Claude Fable 5.1 --- .../pipeline/diarization/speakerkit.py | 4 ++- tests/pipeline/__init__.py | 0 tests/pipeline/test_speakerkit_cli_args.py | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/pipeline/__init__.py create mode 100644 tests/pipeline/test_speakerkit_cli_args.py diff --git a/src/openbench/pipeline/diarization/speakerkit.py b/src/openbench/pipeline/diarization/speakerkit.py index 6dfa908..e8a50cc 100644 --- a/src/openbench/pipeline/diarization/speakerkit.py +++ b/src/openbench/pipeline/diarization/speakerkit.py @@ -46,7 +46,9 @@ def generate_cli_args(self, inputs: SpeakerKitInput) -> list[str]: str(inputs["audio_path"]), "--rttm-path", str(inputs["output_path"]), - "--engine", + # speakerkitpro-cli selects the diarization backend with `--diarizer` (pyannote | sortformer); + # the former `--engine` flag is rejected with "Unknown option '--engine'". + "--diarizer", self.engine, "--verbose", ] diff --git a/tests/pipeline/__init__.py b/tests/pipeline/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/pipeline/test_speakerkit_cli_args.py b/tests/pipeline/test_speakerkit_cli_args.py new file mode 100644 index 0000000..dfbfd9c --- /dev/null +++ b/tests/pipeline/test_speakerkit_cli_args.py @@ -0,0 +1,31 @@ +from pathlib import Path + +from openbench.pipeline.diarization.speakerkit import SpeakerKitPipelineConfig + + +def _config(**overrides) -> SpeakerKitPipelineConfig: + kwargs = {"cli_path": "/opt/speakerkitpro-cli", "out_dir": "./out"} + kwargs.update(overrides) + return SpeakerKitPipelineConfig(**kwargs) + + +def _inputs(num_speakers=None) -> dict: + return {"audio_path": Path("a.flac"), "output_path": Path("a.rttm"), "num_speakers": num_speakers} + + +def test_cli_args_use_diarizer_flag_for_pyannote(monkeypatch): + monkeypatch.delenv("SPEAKERKIT_API_KEY", raising=False) + cmd = _config(engine="pyannote").generate_cli_args(_inputs()) + assert cmd[:2] == ["/opt/speakerkitpro-cli", "diarize"] + assert "--diarizer" in cmd and cmd[cmd.index("--diarizer") + 1] == "pyannote" + assert "--engine" not in cmd + assert "--num-speakers" not in cmd and "--api-key" not in cmd + + +def test_cli_args_sortformer_num_speakers_and_api_key(monkeypatch): + monkeypatch.setenv("SPEAKERKIT_API_KEY", "secret") + cmd = _config(engine="sortformer", model_path="/models").generate_cli_args(_inputs(num_speakers=3)) + assert cmd[cmd.index("--diarizer") + 1] == "sortformer" + assert cmd[cmd.index("--model-path") + 1] == "/models" + assert cmd[cmd.index("--num-speakers") + 1] == "3" + assert cmd[cmd.index("--api-key") + 1] == "secret"