AircraftAudioId — System Workflow

End-to-end pipeline · ADS-B capture · audio recording · dataset building · model training · evaluation

Architecture

RPi 4B Raspberry Pi 4B · dual SDR dongle readsb Receives 1090 MHz ADS-B Serves aircraft.json on :80 NTP sync required RPi Zero 2W Raspberry Pi Zero 2W · USB mic scripts/capture.py 44100 Hz mono int16 Framed PCM stream → TCP :9876 NTP sync required Ubuntu Server i7-7820X · 128 GB DRAM · GTX 2080 scripts/record.py Polls ADS-B · maintains 60s audio ring buffer Saves WAV + metadata JSON on flyover scripts/buildDataset.py Aligns ADS-B timestamps to audio samples Cuts 5s clips · assigns FAA category labels Writes train.csv / val.csv (split by session) scripts/precomputeSpecs.py Writes <clip>.spec.npy alongside each WAV Eliminates per-epoch CPU spectrogram cost scripts/syncToDGX.sh rsync code + dataset/ to DGX Spark Excludes recordings/ (stays local) DGX Spark GB10 · 128 GB unified DRAM · Blackwell scripts/trainDGX.sh Builds Docker (NGC PyTorch arm64) Runs toolchain.py inside container ResNet-18 · mel spec · BCEWithLogitsLoss Saves checkpoints/ scripts/evalDGX.sh Per-class AP / F1 / precision / recall Macro mAP · optional threshold tuning scripts/evalModel.py Single-WAV inference Sorted probability table per class HTTP · JSON poll every 1 s TCP · PCM continuous stream rsync / SSH
RPi 4B ADS-B receiver
RPi Zero 2W Audio capture
Ubuntu Server Recording · dataset building · sync
DGX Spark Training · evaluation · inference

Workflow Steps

1
RPi 4B
Start ADS-B receiver
Run readsb with the SDR dongle to receive 1090 MHz Mode S transponder signals. Serves live aircraft positions as JSON. Clock must be NTP-synced — ADS-B timestamps are the ground truth for audio alignment.
2
RPi Zero 2W
Start audio capture
Captures USB mic at 44100 Hz mono int16. Each chunk is framed with an 8-byte float64 Unix timestamp and a 4-byte length prefix, then sent over TCP. Clock must be NTP-synced; warns if offset exceeds 100 ms.
python audioCapture/scripts/capture.py --host <server-ip> --port 9876
3
Ubuntu
Record flyovers
Polls ADS-B every second and tracks aircraft within the radius. Maintains a 60-second PCM ring buffer. Saves a WAV + metadata JSON when a tracked aircraft departs (last 3 distances increasing) or after the 30s cap. Skips saves if the audio stream is unhealthy. Optional: record background clips on a timer with --nullSampleInterval.
python scripts/record.py \ --lat <lat> --lon <lon> --radiusKm 8 \ --outputDir ./recordings \ --readsbUrl http://adsbrx.lan/data/aircraft.json \ --faaDatabaseDir ./data/ReleasableAircraft \ --nullSampleInterval 300 --nullSampleDuration 10
4
Ubuntu
Build training dataset
Reads recordings and metadata, corrects clock skew, aligns ADS-B state timestamps to audio sample positions, cuts 5-second clips, and assigns FAA category labels via the ReleasableAircraft database. Splits by recording session to prevent data leakage. Produces train.csv, val.csv, and clips/*.wav.
python scripts/buildDataset.py \ --recordingsDir ./recordings \ --outputDir ./dataset \ --faaDatabaseDir ./data/ReleasableAircraft \ --autoCorrectClock \ --maxDistanceKm 4.0 \ --dropUnknown \ --stratifyPhase \ --balanceClasses
5
Ubuntu
Pre-compute spectrograms
Converts each WAV clip to a 128-mel log-power spectrogram and saves it as <clip>.spec.npy alongside the WAV. The training DataLoader loads .npy directly, eliminating the per-epoch CPU bottleneck. Run once after building the dataset; re-run with --skipExisting after adding new clips.
python scripts/precomputeSpecs.py \ --trainCsv dataset/train.csv \ --valCsv dataset/val.csv \ --skipExisting --workers 16
6
Ubuntu
Sync to DGX Spark
rsyncs source code and dataset/ (WAVs, CSVs, .spec.npy files) to the DGX over SSH. Excludes recordings/ — raw audio stays on the server only.
bash scripts/syncToDGX.sh spark-8d0d.local
7
DGX Spark
Train model
Builds the training Docker image (NGC PyTorch arm64 base, bf16-mixed AMP). Runs toolchain.py: ResNet-18 backbone adapted for 1-channel mel spectrogram input, multi-label sigmoid head, BCEWithLogitsLoss with pos_weight balancing, SpecAugment, AdamW + cosine LR schedule. Saves top-3 checkpoints by val_f1; EarlyStopping at patience=10.
bash scripts/trainDGX.sh \ --useCategories \ --freezeBackbone \ --weightDecay 0.05 \ --maxEpochs 60 \ --minClipsPerClass 100
8
DGX Spark
Evaluate checkpoint
Runs the saved checkpoint against val.csv. Prints per-class AP, F1, precision, recall, and support in a sorted table, plus macro mAP and F1. Use the labelEncoder_<timestamp>.json saved alongside each checkpoint to ensure the class mapping matches.
bash scripts/evalDGX.sh \ --checkpoint checkpoints/best.ckpt \ --labelEncoder checkpoints/labelEncoder_<timestamp>.json \ --valCsv dataset/val.csv \ --useCategories --tuneThresholds
9
DGX Spark
Single-clip inference
Run the trained model on a single WAV file. Loads the clip, computes the mel spectrogram, and prints a sorted probability table of all classes with active predictions marked.
python scripts/evalModel.py \ --checkpoint checkpoints/best.ckpt \ --labelEncoder checkpoints/labelEncoder_<timestamp>.json \ --wav /path/to/clip.wav

Wire Protocol & Data Formats

From To Transport Format / Notes
RPi 4B Ubuntu HTTP GET :80 JSON aircraft list — polled every 1 s by ReadsbClient
RPi Zero 2W Ubuntu TCP :9876 [8B float64 Unix timestamp][4B uint32 byte_len][N bytes PCM S16LE] — continuous framed stream; server maintains 60 s ring buffer
Ubuntu Ubuntu local disk recordings/audio/<id>.wav + recordings/metadata/<id>.json per flyover event
Ubuntu Ubuntu local disk dataset/clips/*.wav · dataset/train.csv / val.csv · *.spec.npy
Ubuntu DGX Spark rsync / SSH Source code + dataset/ (includes .spec.npy). Excludes recordings/.
DGX Spark DGX Spark local disk checkpoints/*.ckpt · checkpoints/labelEncoder.json · checkpoints/labelEncoder_<ts>.json