End-to-End Passive Acoustic Monitoring Workflow

An end-to-end workflow for passive acoustic monitoring projects, from raw recordings to data ready for ecological analysis. Standardizes and checks field recordings, runs 'BirdNET' (Kahl et al. 2021 ) through its 'Python' package, cleans and validates detections, and computes soundscape indices. Builds detection histories, count histories and input for occupancy and abundance models, summarizes activity patterns and species richness, and writes 'HTML', 'PDF' and 'Excel' reports. Optional 'shiny' apps support standardization, validation and annotation, and the training of custom 'BirdNET' classifiers.


pamflow pamflow website

R-CMD-check Codecov testcoverage

End-to-end Passive Acoustic Monitoring workflow

pamflow takes you from raw field recordings to ecological useful information — with a single config file and a handful of function calls.

Workflow A (Species Detection & Occupancy): Run BirdNET, clean & merge detections, perform stratified validation with Shiny, build daily site occupancy matrices, and compile executive reports.

Workflow B (Soundscape Analysis): Compute core acoustic indices (ACI, ADI, AEve, Bio, H, M, NDSI) following Bradfer-Lawrence et al. (2019) with 500 Hz low-stop filtering, 1-minute memory-safe sub-chunking, 24-hour diel profiles, and automated HTML diagnostic reports.

Features

  • Raven Compass-style Standardization & Triage for raw multi-recorder workflow (SongMeter, AudioMoth, SwiftOne)
  • Scan & QC thousands of WAV files automatically
  • Batch BirdNET detection with parallel workers and resume support (runs the Python birdnet package; no birdnetR needed)
  • Clean & merge overlapping detections into events
  • Interactive validation via Shiny app with precision metrics
  • Occupancy detection histories (1/0 matrices per site per species; occasion length set in the config)
  • Activity, richness and diversity from the detections and the recording effort: species thresholds from validation, activity patterns by hour or season, Hill numbers, species accumulation
  • Input for occupancy and abundance models (unmarked, ubms, spOccupancy): count histories for one or many species and seasons, with covariates and checks. pamflow prepares the data; it does not fit the models
  • Standalone BirdNET training tool (separate from the workflow): train your own classifier from R or in a point-and-click app, with per-class test results
  • Ecoacoustic Soundscape Indices Dynamic computation of ACI, ADI, AEve, Bio, H, M, and NDSI.
  • Soundscape Visualizations & HTML Reports 24-hour diel profiles, Day vs. Night comparisons, site covariate tables, and standalone HTML reports.

Prerequisites

Software Version Notes
R ≥ 4.3 64-bit
uv latest Creates pamflow’s private Python environment for BirdNET
FFmpeg any Required for audio clipping

On Windows install uv with winget install --id astral-sh.uv (other systems: see https://docs.astral.sh/uv/). pamflow downloads the Python version it needs, so no system Python is required.

Verify in R after installing pamflow:

R.version.string           # ≥ 4.3
system("ffmpeg -version")  # prints version
pamflow::pam_birdnet_doctor()

Installation

# Install devtools if needed
install.packages("devtools")

# Install pamflow
devtools::install_github("pradeeshwarrj/pamflow")

# Create the Python environment BirdNET runs in (once; downloads TensorFlow, a few minutes)
pamflow::pam_birdnet_setup("inference")
# Optional, only for the standalone model-training tool (see "Training a custom BirdNET classifier"):
pamflow::pam_birdnet_setup("training")

Try it without any data

pam_example_project() builds a tiny synthetic project in a temporary folder: six short recordings, a deployment sheet, a config and a small detections file. You can see how the stages work before using your own recordings. It needs no FFmpeg, Python or internet connection.

library(pamflow)

ex <- pam_example_project()             # created in a temporary folder
res <- pam_scan_audio(ex$cfg)           # Stage 1: scan the recordings
res$summary$overall                     # files, grids, hours, QC results

out <- pam_process_detections(ex$cfg)   # Stage 4: clean the example detections
out$steps                               # what each cleaning rule removed

occ <- pam_build_occupancy(ex$cfg)      # Stage 6: detection histories
occ$histories[[1]]

act <- pam_activity(ex$cfg)             # activity by hour of the day
rich <- pam_richness(ex$cfg)            # richness and diversity per site
rich$sites

Open ex$root in your file browser to see what each stage wrote. Every help page has an example built on this project, for instance ?pam_validation_draw or example("pam_scan_audio"). To keep the sandbox, give it a folder: pam_example_project("C:/pamflow_sandbox").

Quick Start

1. Set up your project folder

MyProject/
├── data/
│   └── raw/                # Original recorder dumps (untouched)
│       ├── SongMeter/
│       ├── AudioMoth/
│       └── SwiftOne/
├── metadata/
│   └── deployments.csv     # one row per deployment
├── models/
│   └── custom_classifier/  # your .tflite model and _Labels.txt
└── config/
    └── config.yml          # your settings

pamflow creates the other folders (data/standardized/, data/detections/, data/occupancy/, logs/, reports/ …) as the stages run.

2. Create metadata/deployments.csv

One row per deployment. Columns are read by position, so keep this order (dates as dd-mm-yyyy, times as hh:mm; give the grid as a number, for example 59 for G0059):

deployment_id,recorder,grid,habitat,deployer,latitude,longitude,deploy_date,deploy_time,retrieve_date,retrieve_time
13,SW010,59,Forest,Asha,7.01,93.82,05-04-2026,18:30,08-04-2026,16:00
7,SW012,110,Plantation,Ravi,7.05,93.85,01-04-2026,06:00,10-04-2026,18:00

3. Create config/config.yml

You only need to set what differs from the defaults; every setting you leave out falls back to the template that ships with pamflow.

paths:
  project_root: "E:/MyProject"          # all other paths are relative to this folder

filenames:
  pattern: "^(?<grid>G\\d{4})_(?<date>\\d{8})_(?<time>\\d{6})(_chunk\\d+)?\\.(flac|wav)$"
  timezone: "Asia/Kolkata"

birdnet:
  run_id: "run01"
  model_dir: "models/custom_classifier"   # folder with your .tflite and _Labels.txt
  classifier_name: "CustomClassifier"     # files: <name>.tflite and <name>_Labels.txt
  min_confidence: 0.3
  workers: null                           # null = half of the physical cores

occupancy:
  run_id: "run01"
  occasion_length_days: 1

project_root can be a full path, as above, or a path relative to the folder that holds the config file: ".." (the template’s default) means the folder above config/. Relative paths are never read from your working directory, and pam_config_read() always needs the path of the config file.

To see every setting, copy the full template and edit it:

file.copy(system.file("extdata", "config_template.yml", package = "pamflow"),
          "config/config.yml")

4. Run the pipeline

Stage 00: Standardization & Data Triage (Raven Compass)

Raw multi-recorder dumps are often messy (mixed formats, voice memos, field notes, inconsistent filenames). Stage 00 standardizes them without modifying original raw files.

Interactive Shiny App

library(pamflow)
cfg <- pam_config_read("E:/MyProject/config/config.yml")
pam_standardization_app(cfg)   # folders are filled in from the config

The GUI provides three tabs:

  • Inspect — Preview files, extract metadata, test filename regex

  • Convert — Batch convert and organize into standardized folders

  • Log — Live processing log

The validation (pam_validate()) and annotation (pam_annotate()) apps share this look, with a light and dark mode.

Headless Standardization R

library(pamflow)
cfg <- pam_config_read("E:/MyProject/config/config.yml")

pam_standardize(cfg)     # raw -> data/standardized, memos and non-audio -> data/isolated

What Stage 00 does:

  • Extracts grid IDs and timestamps from SongMeter, AudioMoth, and SwiftOne filenames

  • Isolates voice memos (< 60 s), text logs, and unreadable files into data/isolated/

  • Converts and renames audio into a uniform structure under data/standardized/G####/

  • Leaves all original raw files untouched

Workflow A: Detection & Occupancy Pipeline

library(pamflow)
cfg <- pam_config_read("E:/MyProject/config/config.yml")

# Stage 00: Standardize raw recorder dumps (if not done via Shiny app)
pam_standardize(cfg)

# Stage 1: Scan audio and check deployments
pam_scan_audio(cfg)

# Stage 2 (optional): high-pass filter the QC-passed files
# pam_filter_audio(cfg)

# Stage 3: Run BirdNET detection (parallel, resumable)
pam_detect(cfg)

# Stage 4: Clean, filter, and merge detections
pam_process_detections(cfg)

# Stage 5: Validate a sample of detections
pam_validation_draw(cfg)
pam_validation_export(cfg)
pam_validation_app(cfg)          # opens Shiny app in browser

# After closing the app:
val  <- pam_validation_import(cfg)
pool <- pam_validation_pool(cfg)
pam_validation_metrics(val, pool, bands = c(0.5, 0.6, 0.7, 0.8, 0.9))

# Stage 5b (optional): ground-truth segments to estimate recall
# pam_recall_draw(cfg); pam_recall_export(cfg)

# Stage 6: Build occupancy detection histories
pam_build_occupancy(cfg)

# Stage 7: Input for occupancy and abundance models (you fit them yourself)
hist <- pam_count_history(cfg, species = "Gracula religiosa")
x <- pam_model_input(hist, binary = TRUE)   # y, siteCovs, obsCovs

# Stage 8: Generate species detection reports
pam_report(cfg)

Workflow B: Soundscape Analysis Pipeline

library(pamflow)
cfg <- pam_config_read("E:/MyProject/config/config.yml")

# Stage 00: Standardize raw recorder dumps
pam_standardize(cfg)

# Stage 1: Scan audio and check deployments
pam_scan_audio(cfg)

# Stage 2b: Calculate soundscape indices (ACI, Bio, NDSI, etc.)
sc_results <- pam_soundscape_run(cfg)

# Stage 2c: Generate 24-hour diel plots, Day/Night comparisons & HTML Report
vis_results <- pam_soundscape_run_vis(cfg)

Beyond occupancy: activity, richness and model input

The cleaned detections can answer more than occupancy questions. These functions use the recording effort, so sites and periods recorded for different lengths of time can be compared. pamflow prepares the input for occupancy and abundance models but does not fit them: use unmarked, ubms, spOccupancy or any other package.

# One confidence threshold per species, from the Stage 5 validation
thr <- pam_species_thresholds(cfg, write = TRUE)

# Activity: detections per recorded hour, by hour of day, day, week or month
act <- pam_activity(cfg, by = "hour")
pam_plot_activity(act)

# Richness, Hill numbers, species accumulation and the Chao2 estimate
rich <- pam_richness(cfg)
rich$sites
pam_plot_richness(rich)

# Input for occupancy and abundance models (one species, or many, and seasons)
hist <- pam_count_history(cfg, species = "Gracula religiosa")
x <- pam_model_input(hist, binary = TRUE)    # y, siteCovs, obsCovs
pam_check_model_input(x)
umf <- unmarked::unmarkedFrameOccu(y = x$y, siteCovs = x$siteCovs, obsCovs = x$obsCovs)

Occasions follow occupancy.occasion_length_days in the config. See the guide (vignette("pamflow-guide")) for several species, several seasons and the details of each function.

Pipeline Stages

Workflow Stage Function What it does
Both 00 pam_standardize() / pam_standardization_app() Raven Compass-style triage: metadata extraction, memo isolation (<60s), non-audio log separation, FLAC/WAV standardization
Both 1 pam_scan_audio() Inventories audio files, matches to deployments, flags QC issues
Both 2 pam_filter_audio() High-pass filter on the QC checked files; can be customized
B 2b pam_soundscape_run() Computes soundscape indices per 10-min window with 500Hz high-pass filter
B 2c pam_soundscape_run_vis() Plots 24-hour diel profiles, Day/Night comparisons, and generates HTML report
A 3 pam_detect() Runs BirdNET on all files in parallel batches; resumable
A 4 pam_process_detections() Filters by confidence, deployment window, species; merges overlapping windows
A 5 pam_validation_draw() Draws a stratified random sample for manual review
A 5 pam_validation_export() Cuts short WAV clips around each sampled detection
A 5 pam_validation_app() Shiny app to listen and confirm/reject species
A 5 pam_validation_metrics() Computes precision by species and confidence band
A 5b pam_recall_draw() / pam_recall_export() / pam_recall_metrics() Optional ground-truth segments to estimate recall
A 6 pam_build_occupancy() Builds detection matrices (occasion length from the config), effort, and site covariates
A 7 pam_count_history() / pam_count_histories() Counts of one or many species by site and occasion, with effort and covariates
A 7 pam_model_input() / pam_define_seasons() / pam_check_model_input() Input for unmarked, ubms or spOccupancy, for one or many species and seasons, checked before fitting
A Eco pam_species_thresholds() One confidence threshold per species from the validation
A Eco pam_activity() / pam_richness() Activity patterns and species richness and diversity from the detections
A 8 pam_report() Generates HTML, PDF and Excel reports, including richness and activity

Note: All stage functions take cfg as their primary argument. The run_id is read from the config file. Stage 00 can also be run interactively via pam_standardization_app().

Training a custom BirdNET classifier (standalone tool)

Training your own classifier is separate from the workflow: it is not a pipeline stage, no stage function calls it, and the workflow runs without it. Use it when you need a .tflite model to give to Stage 3.

# Once: the training environment (downloads BirdNET-Analyzer and TensorFlow)
pamflow::pam_birdnet_setup("training")

# Point-and-click app, laid out like the BirdNET-Analyzer GUI training tab
pamflow::pam_train_app()

# Or from code
pamflow::pam_birdnet_train_prepare("E:/clips")            # check the training folder
res <- pamflow::pam_birdnet_train("E:/clips", "E:/models/MyModel",
                                  test_data = "E:/clips_test")
res$evaluation$classes                                     # precision, recall, F1, AUPRC, AUROC per class

It runs BirdNET-Analyzer’s own birdnet-train (version 2.4.0), so results match the Analyzer GUI, and it works on Windows without WSL or a GPU. The app shows live progress and learning curves, per-class test results, earlier runs, a light and dark theme, and the birdnet: config lines for the new model. To use the model, set birdnet$model_dir and birdnet$classifier_name in your config.

Outputs

MyProject/
├── data/
│   ├── raw/                         # Original recorder dumps (never modified)
│   ├── standardized/                # Standardized audio (from Stage 00)
│   │   ├── G0059/
│   │   └── G0110/
│   ├── isolated/                    # Memos, logs, corrupt files (from Stage 00)
│   ├── filtered/                    # Only if you run the optional filter (Stage 2)
│   ├── soundscape/run01/
│   │   ├── soundscape_raw.csv
│   │   ├── soundscape_hourly.csv
│   │   ├── soundscape_diel_summary.csv
│   │   ├── soundscape_site_covariates.csv
│   │   ├── plots/
│   │   │   ├── diel_hourly_aci.png
│   │   │   └── diel_phase_aci.png
│   │   └── reports/
│   │       └── Soundscape_Report_run01.html
│   ├── detections/run01/
│   │   ├── batches/
│   │   ├── processed/
│   │   └── validation/              # Sampled events, clips and your verdicts (Stage 5)
│   ├── validation/ground_truth/     # Recall segments (Stage 5b)
│   └── occupancy/run01/
│       ├── detection_matrices/
│       ├── effort.csv
│       ├── site_covariates.csv
│       └── occupancy_summary.csv
├── metadata/
│   ├── audio_headers.csv
│   └── audio_master.csv             # Every recording with deployment match and QC flags
├── outputs/
│   ├── deployment_issues.csv
│   └── audio_summary_per_grid.csv
├── reports/
└── logs/

Configuration Reference

The most-used settings and their defaults (the full list is in the template, see step 3 above).

Section Key Default Description
filenames timezone "Asia/Kolkata" Timezone for filename date-times and deployment dates
standardization min_duration_s 60 Files shorter than this are isolated as memos
standardization target_format "flac" Output audio format (flac or wav)
birdnet run_id "run01" Name of this detection run
birdnet input "standardized" Audio to scan: "standardized" or "filtered"
birdnet model_dir "models/custom_classifier" Folder with your .tflite model and _Labels.txt
birdnet classifier_name "CustomClassifier" Model file name without .tflite
birdnet workers null Worker processes; null = half of the physical cores
birdnet min_confidence 0.3 Minimum BirdNET score to keep
birdnet chunk_size 100 Files per batch; progress is saved after each batch
processing min_confidence 0.5 Minimum confidence kept after processing
processing merge_gap_s 3 Gap (seconds) for merging overlapping detections
processing drop_outside_deployment true Remove detections outside deployment windows
processing species_thresholds_file null CSV with scientific_name and threshold; see pam_species_thresholds()
occupancy occasion_length_days 1 Days per occasion; also the default time bin of the Stage 7 and ecological functions
occupancy min_effort_hours 2 Minimum recording hours in an occasion for it to count as surveyed
occupancy min_detections 10 Minimum total detections to include a species

Resumability

If pam_detect() is interrupted (power loss, crash, etc.), simply run it again. It checks for completed batches and picks up where it left off.

Citing BirdNET and pamflow

pamflow runs BirdNET but does not include it. If you use pamflow with BirdNET, please cite the BirdNET paper:

Kahl, S., Wood, C. M., Eibl, M. and Klinck, H. (2021). BirdNET: A deep learning solution for avian diversity monitoring. Ecological Informatics, 61, 101236. https://doi.org/10.1016/j.ecoinf.2021.101236

The BirdNET models and the BirdNET-Analyzer are licensed by their authors (research and educational use is non-commercial and free; check each model’s license before other uses). To cite pamflow itself, run citation("pamflow").

License

MIT

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("pamflow")

0.6.1 by Pradeeshwar Rajagopal James, 8 hours ago


https://pradeeshwarrj.github.io/pamflow/, https://github.com/pradeeshwarrj/pamflow


Report a bug at https://github.com/pradeeshwarrj/pamflow/issues


Browse source code at https://github.com/cran/pamflow


Authors: Pradeeshwar Rajagopal James [aut, cre, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports av, cli, data.table, fs, ggplot2, glue, parallel, processx, ps, rlang, seewave, shiny, stats, tools, tuneR, utils, withr, yaml

Suggests knitr, openxlsx, reticulate, rmarkdown, rstudioapi, soundecology, tcltk, testthat, unmarked

System requirements: FFmpeg (audio conversion, filtering and clips); uv (creates the optional Python environment for 'BirdNET')


See at CRAN