From c083e9b04878095af11850344bde68c82fd9f2c3 Mon Sep 17 00:00:00 2001 From: pham-tuan-binh Date: Wed, 30 Sep 2026 16:37:34 -0500 Subject: [PATCH] Fix run_extraction TypeError in augment/run CLI commands #73 made sess_options a required positional argument of run_extraction, but the augment and run CLI commands still call run_extraction(config), so both crash with a TypeError after augmentation. Default sess_options to None, matching WakeWordModel, and add a regression test. --- src/livekit/wakeword/data/features.py | 2 +- tests/test_feature_extractor.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/livekit/wakeword/data/features.py b/src/livekit/wakeword/data/features.py index ffab2da..94aed98 100644 --- a/src/livekit/wakeword/data/features.py +++ b/src/livekit/wakeword/data/features.py @@ -69,7 +69,7 @@ def extract_features_from_directory( return np.stack(all_features, axis=0) # (N_clips, 16, 96) -def run_extraction(config: WakeWordConfig, sess_options: SessionOptions) -> None: +def run_extraction(config: WakeWordConfig, sess_options: SessionOptions | None = None) -> None: """Extract and save features for all splits of a wake word config.""" mel_frontend = MelSpectrogramFrontend( onnx_path=get_mel_model_path(), diff --git a/tests/test_feature_extractor.py b/tests/test_feature_extractor.py index f25889c..8f5d49c 100644 --- a/tests/test_feature_extractor.py +++ b/tests/test_feature_extractor.py @@ -49,3 +49,14 @@ def test_nonexistent_onnx_raises(self, tmp_path): """Non-existent ONNX path should raise FileNotFoundError.""" with pytest.raises(FileNotFoundError): MelSpectrogramFrontend(onnx_path=tmp_path / "nonexistent.onnx") + + +class TestRunExtraction: + """Test the run_extraction entry point used by the CLI.""" + + def test_callable_without_sess_options(self, sample_config): + # The `augment` and `run` CLI commands call run_extraction(config) with no + # sess_options; this must not raise TypeError. + from livekit.wakeword.data.features import run_extraction + + run_extraction(sample_config)