Program#
Pre-Built Program#
acoupi_batdetect2.program
#
Batdetect2 Program.#
This module builds the BatDetect2 Program to record, detect and classify, as well as
manage and send messages of UK bat calls. The program extends the DetectionProgram
and MessagingProgram
from the acoupi package by adding the BatDetect2 model
and integrating users' custom configuration schema.
Key Elements:#
- BatDetect2_ConfigSchema: Defines the configuration for the BatDetect2 program, including the audio recording, model setup, file management, messaging, and summariser settings.
Program Tasks:#
- recording_task: Records audio from a microphone and saves the audio files
in a temporary directory until they have been processed by the
detection
andmanagement
tasks. Based on theSavingFilters
configuration, recordings will either saved or deleted. - detection_task: Runs the BatDetect2 model on the audio recordings, processes
the detections, and can use a custom
ModelOutputCleaner
to filter out unwanted detections (e.g., low-confidence results). The filtered detections are saved in ametadata.db
file. - management_task: Performs periodically file management operations, such as moving recording to permanent storage, or deleting unnecessary ones.
- messaging_task: Send messages stored in the message store using a configured protocol (HTTP or MQTT).
- summary_task: Periodically creates summaries of the detections.
Customisation Options:#
-
ModelConfig: Set the
detection_threshold
to clean out the output of the BatDetect2 model. Detections with a confidence score below this threshold will be excluded from the store and from the message content. -
SaveRecordingManager: Define where recordings are stored, the naming format, and the minimum confidence score for saving recordings. Recordings with confidence scores below the
saving_threshold
will not be saved. Thesaving_threshold
can be set lower than thedetection_threshold
to save recordings with uncertain detections. Recordings with detections above thedetection_threshold
will be saved in thetrue_dir
directory, while recordings with detections below thedetection_threshold
but above thesaving_threshold
will be saved in thefalse_dir
directory. -
SaveRecordingFilter: Define additional saving filters for saving recordings.
- A timeinterval interval fitler that saves recordings whthin a specific time
window, set by the
starttime
andendtime
parameters. - A frequency filter that saves recordings for a specific duration
(in minutes) at defined interval (in minutes), set by the
frequency_duration
andfrequency_interval
parameters. - A before dawn/dusk filter to save recording for a defined duration
(in minutes) before dawn and dusk, set by the
before_dawndusk_duration
. - An after dawn/dusk filter to save recording for a defined duration
(in minutes) after dawn and dusk, set by the
after_dawndusk_duration
. - A saving threshold filter to save recording with detection above a specific
treshold, set by the
saving_filter
parameter.
- A timeinterval interval fitler that saves recordings whthin a specific time
window, set by the
-
SummariserConfig: Define the interval for summarising detections. By default, the summariser calculates the minimum, maximum, and average confidence scores of the total number of detections for each time interval. If the
low_band_threshold
,mid_band_threshold
, andhigh_band_threshold
are set to values greater than 0.0, it also summarises the number of detections in each band (low, mid, high).
Classes:
Name | Description |
---|---|
BatDetect2_Program |
BatDetect2 Program Configuration. |
Classes#
BatDetect2_Program
#
Bases: DetectionProgram[BatDetect2_ConfigSchema]
BatDetect2 Program Configuration.
Methods:
Name | Description |
---|---|
configure_model |
Configure the BatDetect2 model. |
get_file_managers |
Get the file managers for the BatDetect2 Program. |
get_message_factories |
Get the message factories for the BatDetect2 Program. |
get_recording_filters |
Get the recording filters for the BatDetect2 Program. |
get_summarisers |
Get the summarisers for the BatDetect2 Program. |
setup |
Set up the BatDetect2 Program. |
Attributes:
Name | Type | Description |
---|---|---|
config_schema |
|
Attributes#
config_schema = BatDetect2_ConfigSchema
class-attribute
instance-attribute
#
Functions#
configure_model(config)
#
get_file_managers(config)
#
Get the file managers for the BatDetect2 Program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
BatDetect2_ConfigSchema
|
The configuration schema for the acoupi_batdetect2 program defined in the configuration.py file and configured by a user via the CLI. |
required |
Returns:
Type | Description |
---|---|
list[RecordingSavingManager]
|
A list of file managers for the batdetect2 program. |
get_message_factories(config)
#
Get the message factories for the BatDetect2 Program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
BatDetect2_ConfigSchema
|
The configuration schema for the acoupi_batdetect2 program defined in the configuration.py file and configured by a user via the CLI. |
required |
Returns:
Type | Description |
---|---|
list[MessageBuilder]
|
A list of message factories for the batdetect2 program. By default,
the message factory will use the |
get_recording_filters(config)
#
Get the recording filters for the BatDetect2 Program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
BatDetect2_ConfigSchema
|
The configuration schema for the acoupi_batdetect2 program defined in the configuration.py file and configured by a user via the CLI. |
required |
Returns:
Type | Description |
---|---|
list[RecordingSavingFilter]
|
A list of recording filters for the batdetect2 program. If no saving filters are defined, the method will not save any recordings. |
get_summarisers(config)
#
Get the summarisers for the BatDetect2 Program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
BatDetect2_ConfigSchema
|
The configuration schema for the acoupi_batdetect2 program defined in the configuration.py file and configured by a user via the CLI. |
required |
Returns:
Type | Description |
---|---|
list[Summariser]
|
A list of summarisers for the batdetect2 program. By default,
the summariser will use the |
setup(config)
#
Set up the BatDetect2 Program.
This method initialises the batdetect2 program, registers the recording, detection, management, messaging, and summariser tasks, and performs any necessary setup for the program to run.