From ee586ae60237ff7d7159e720a333d68327836f4b Mon Sep 17 00:00:00 2001 From: Stefan Kahl Date: Fri, 16 Feb 2024 09:00:10 -0500 Subject: [PATCH] add bandpass --- README.adoc | 1 + embeddings.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.adoc b/README.adoc index ae6302ae..9f6a7ff2 100644 --- a/README.adoc +++ b/README.adoc @@ -502,6 +502,7 @@ Here's a complete list of all command line arguments: --overlap, Overlap of prediction segments. Values in [0.0, 2.9]. Defaults to 0.0. --threads, Number of CPU threads. --batchsize, Number of samples to process at the same time. Defaults to 1. +--fmin and --fmax, Minimum and maximum frequency for bandpass filter. Defaults to 0 and 15000. ---- + . After the analysis, run `segments.py` to extract short audio segments for species detections to verify results. diff --git a/embeddings.py b/embeddings.py index ee2d4d78..4ad70f46 100644 --- a/embeddings.py +++ b/embeddings.py @@ -143,6 +143,18 @@ def analyzeFile(item): parser.add_argument( "--batchsize", type=int, default=1, help="Number of samples to process at the same time. Defaults to 1." ) + parser.add_argument( + "--fmin", + type=int, + default=cfg.SIG_FMIN, + help="Minimum frequency for bandpass filter in Hz. Defaults to {} Hz.".format(cfg.SIG_FMIN) + ) + parser.add_argument( + "--fmax", + type=int, + default=cfg.SIG_FMAX, + help="Maximum frequency for bandpass filter in Hz. Defaults to {} Hz.".format(cfg.SIG_FMAX) + ) args = parser.parse_args() @@ -165,6 +177,10 @@ def analyzeFile(item): # Set overlap cfg.SIG_OVERLAP = max(0.0, min(2.9, float(args.overlap))) + # Set bandpass frequency range + cfg.BANDPASS_FMIN = max(0, min(cfg.SIG_FMAX, int(args.fmin))) + cfg.BANDPASS_FMAX = max(cfg.SIG_FMIN, min(cfg.SIG_FMAX, int(args.fmax))) + # Set number of threads if os.path.isdir(cfg.INPUT_PATH): cfg.CPU_THREADS = int(args.threads)