stevafernandes/bee-sound
Hive Sound Predictability
Which quantities in the colony workbook can be predicted from a two-minute hive recording, and which cannot? The Space predicts every target (colony survival within 0-3 and 4-6 months, presence, level and high load of each measured pathogen: CBPV, DWV, KBV) from uploaded audio and, next to each prediction, shows the colony-grouped validation evidence for that target. Targets that the validation found not distinguishable from chance are labelled "no evidence of predictability from sound" and their calls are greyed out. The full analysis is in REPORT.md (tab "Report") and the survival-factor analysis in artifacts/results/survival_report.md (tab "Survival factors").
Pipeline (all code in this repository)
Shared modules: acoustic.py (identical feature code at training and inference), data.py (workbook loader and data-driven target registry: a new workbook column such as a Varroa count becomes a target automatically), gemini_audio.py (google-genai SDK; structured listening and a summary constrained to the computed numbers).
Gemini
Set the Space secret GEMINI_API_KEY. Without it the app runs without the Gemini panels. The model list is configurable with GEMINI_MODELS (default gemini-3.8-flash,gemini-flash-latest).
Reproduce
pip install -r requirements.txt
python extract_features.py --audio-dir /path/to/wav --what handcrafted ast clap
GEMINI_API_KEY=... python gemini_batch.py --audio-dir /path/to/wav --retest 1131
python evaluate.py --audio-dir /path/to/wav --n-perm 100
python survival_analysis.py --audio-dir /path/to/wav
python train_models.py --audio-dir /path/to/wav
python make_report.py
python make_examples.py --audio-dir /path/to/wav
python -m pytest tests -q
python app.pyDeploy
The Space needs, next to the code: models/ (config.json, oofpredictions.json and the *.joblib files written by `trainmodels.py), AIDataTraining.xlsx, REPORT.md, artifacts/results/ and, optionally, examples/*.wav. Without models/config.json` the app starts but prediction is disabled and a message says what is missing (the report and evidence tabs still work).
git clone https://huggingface.co/spaces/<user>/<space>
cp -r hf_space/. <space>/ && cd <space>
git lfs install && git lfs track "*.wav" "*.xlsx"
git add . && git commit -m "Hive sound predictability" && git pushartifacts/features/*.npz (embedding caches, only needed to retrain) are git-ignored and not required by the app. Every model file is below 1 MB, so no LFS is needed for models/. Set the Space secret GEMINI_API_KEY for the Gemini panels. The first prediction after a cold start downloads the AST weights (about 350 MB); the app starts that download in the background at launch.
