From 9ec2f1a107544baebe3c962f30a863d5fba4698c Mon Sep 17 00:00:00 2001 From: mbsantiago Date: Sat, 28 Mar 2026 11:09:47 +0000 Subject: [PATCH] Add audio dir to data cli command --- src/batdetect2/cli/data.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/batdetect2/cli/data.py b/src/batdetect2/cli/data.py index 20aa3e9..51b7e4a 100644 --- a/src/batdetect2/cli/data.py +++ b/src/batdetect2/cli/data.py @@ -80,11 +80,17 @@ def summary( type=click.Path(exists=True), help="The base directory to which all recording and annotations paths are relative to.", ) +@click.option( + "--audio-dir", + type=click.Path(exists=True), + help="The directory containing the audio files. All paths will be relative to this directory.", +) def convert( dataset_config: Path, field: str | None = None, output: Path = Path("annotations.json"), base_dir: Path | None = None, + audio_dir: Path | None = None, ): """Convert a dataset config file to soundevent format.""" from soundevent import data, io @@ -103,4 +109,12 @@ def convert( description=config.description, ) - io.save(annotation_set, output) + if audio_dir: + audio_dir = Path(audio_dir) + + if not audio_dir.is_absolute(): + audio_dir = audio_dir.resolve() + + print(f"Using audio directory: {audio_dir}") + + io.save(annotation_set, output, audio_dir=audio_dir)