diff --git a/batdetect2/cli.py b/batdetect2/cli.py index f82c5c3..66aada8 100644 --- a/batdetect2/cli.py +++ b/batdetect2/cli.py @@ -5,6 +5,7 @@ import click from batdetect2 import api from batdetect2.detector.parameters import DEFAULT_MODEL_PATH +from batdetect2.types import ProcessingConfiguration from batdetect2.utils.detector_utils import save_results_to_file CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -104,17 +105,23 @@ def detect( **{ **params, **args, - 'time_expansion': time_expansion_factor, + "time_expansion": time_expansion_factor, "spec_slices": False, "chunk_size": 2, "detection_threshold": detection_threshold, } ) + if not args["quiet"]: + print_config(config) + # process files error_files = [] - for audio_file in files: + for index, audio_file in enumerate(files): try: + if not args["quiet"]: + click.echo(f"\n{index} {audio_file}") + results = api.process_file(audio_file, model, config=config) if args["save_preds_if_empty"] or ( @@ -135,5 +142,12 @@ def detect( click.echo(f" {err}") +def print_config(config: ProcessingConfiguration): + """Print the processing configuration.""" + click.echo("\nProcessing Configuration:") + click.echo(f"Time Expansion Factor: {config.get('time_expansion')}") + click.echo(f"Detection Threshold: {config.get('detection_threshold')}") + + if __name__ == "__main__": cli() diff --git a/batdetect2/utils/detector_utils.py b/batdetect2/utils/detector_utils.py index dd010f9..d6d2b13 100644 --- a/batdetect2/utils/detector_utils.py +++ b/batdetect2/utils/detector_utils.py @@ -731,7 +731,6 @@ def process_file( spec_slices = [] # load audio file - print("time_exp_fact", config.get("time_expansion", 1) or 1) sampling_rate, audio_full = au.load_audio( audio_file, time_exp_fact=config.get("time_expansion", 1) or 1, diff --git a/pdm.lock b/pdm.lock index 68480c5..e625f95 100644 --- a/pdm.lock +++ b/pdm.lock @@ -453,7 +453,7 @@ summary = "Backport of pathlib-compatible object wrapper for zip files" [metadata] lock_version = "4.1" -content_hash = "sha256:2401b930c14b3b7e107372f0103cccebff74691b6bcd54148d832ce847df5673" +content_hash = "sha256:667d4d2891fb85565cb04d84d0970eaac799bf272e3c4d7e4e6fea0b33c241fb" [metadata.files] "appdirs 1.4.4" = [ diff --git a/tests/test_cli.py b/tests/test_cli.py index 8fbd41b..767be7e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -66,4 +66,4 @@ def test_cli_detect_command_with_non_trivial_time_expansion(tmp_path): ) assert result.exit_code == 0 - assert 'time_exp_fact 10' in result.stdout + assert 'Time Expansion Factor: 10' in result.stdout