Inspiration
“Show me the incentive, and I'll show you the outcome.” (Charlie Munger, Harvard 1995)
In industrial livestock farming, producers face powerful incentives to increase herd sizes, improve productivity, and minimize operating costs. But investments in facilities, labor, and veterinary oversight don't scale proportionately.
As a result, farmers find themselves responsible for thousands of animals, where by the time an infection becomes visibly apparent, it may have already spread throughout the herd, risking widespread mortality, commercial losses from herd depopulation, and the waste of substantial resources invested in feed, water, energy, and land.
Through a mentor discussion, Marc challenged us to think about doing what felt impossible: What if we used data to train AI to identify cues in animal sounds – i.e. What if we could UNDERSTAND animals?
Animals communicate constantly through coughs, grunts, squeals, screams, and other vocalizations. Research suggests that some of these sounds contain identifiable information about animal health and welfare. For example, Norton et al. (2019) reported an 85% overall classification rate, including 82% correct identification of sick cough sounds.[^1] Earlier work by Exadaktylos et al. (2008) demonstrated the potential for acoustic monitoring to identify respiratory disease before conventional observation.[^2]
This inspired a fascinating technical question: Can we teach AI to recognize meaningful patterns in animal communication?
And practically: How can we apply this cue detection to promote sustainable livestock farming practices?
Precision livestock farming (PLF) already uses sensors and software to help producers monitor animal populations. We saw an opportunity to make that monitoring more accessible, continuous, and actionable without requiring a wearable device on every animal.
So for HackHarvard 2026, we built Oinkalytics, an ==infection-detection system that utilizes the animal’s own calls of distress to maintain sustainable commercial farming at scale.==
What it does
Oinkalytics transforms animal vocalizations into actionable, evidence-based alerts.
Our system analyzes pig and chicken audio, classifying vocalizations as calm, distressed, or uncertain. Rather than interpreting every squeal or cough as an emergency, Oinkalytics evaluates patterns over time.
When three of the last five confident classifications indicate distress, the system triggers a pen-level alert.
Farmers can monitor their animals through an interactive dashboard or receive alerts directly through iMessage, powered by Photon.
They can respond with:
whyto understand the evidence behind an alert.play itto hear the original audio recording.statusto review the condition of monitored pens.
How we built it
We built Oinkalytics around Google DeepMind's Perch 2.0 bioacoustics model, which transforms audio recordings into 1,536-dimensional embeddings.
These embeddings provide a compact representation of acoustic information, allowing us to train lightweight classifiers using scikit-learn to distinguish distress-related vocalizations.
Our pipeline combines audio processing, machine learning, confidence calibration, temporal alert logic, and real-time messaging.
To make predictions more reliable, we implemented calibrated confidence scores, an uncertainty band that allows the classifier to abstain, and a rolling 3-of-5 alert rule intended to reduce false positives.
Our technical stack includes Python, FastAPI, scikit-learn, Gradio, TypeScript, and Photon.
We also developed an interactive barn simulator, an audio analysis interface, and evidence-grounded explanations designed to prevent hallucinations.
Accomplishments that we're proud of
We developed an end-to-end prototype that processes animal audio, identifies potential distress, tracks pen-level patterns, and delivers alerts directly to a farmer's phone.
We integrated bioacoustic foundation-model embeddings with lightweight classifiers, temporal alert logic, an interactive monitoring dashboard, and two-way messaging.
Our confidence calibration achieved an error of 0.023, and our explanation safeguards passed 28 out of 28 tests.
We also evaluated the system against unfamiliar recordings, environmental noise, and sounds from other species.
Our proudest accomplishment was designing a system that can say "I don't know."
In a setting where false alarms can erode trust and missed warnings can have real welfare consequences, uncertainty is information that needs to be considered.
Challenges we ran into
Our biggest challenge was realizing that our best results were misleading.
| Test | Headline result | What held up |
|---|---|---|
| Pig classifier accuracy | 90% (random split) | 67.5% (unfamiliar recordings) |
| False alarms on calm pigs, heavy noise | 31% | 14% (after targeted noise training) |
| Chicken classifier accuracy | 99.6% | 93.9% (seven simple acoustic features, same dataset) |
Our pig classifier initially scored 90%. On unfamiliar recordings, it dropped to 67.5%.
Then our chicken classifier achieved an astonishing 99.6% accuracy.
We almost celebrated. Until seven simple acoustic features achieved 93.9% on the same dataset.
Was our AI learning meaningful animal signals, or just shortcuts hidden in the recordings?
Realistic background noise exposed another weakness. False alarms on calm pigs reached 31% under heavy noise. After targeted noise training, we reduced that to 14%.
We even discovered that our demo recordings accidentally contained clues that could reveal their labels. So we rebuilt the evaluation instead of ignoring the problem.
What we learned
We saw the gap between research and actionable deployment and how there are amazing opportunities in designing systems that intermediate the application of academic theory for the people who can actually apply it in real life.
A model with 99.6% accuracy isn't necessarily a model that understands what it's hearing.
We learned how random dataset splits can obscure generalization problems, how environmental noise can distort predictions, and how seemingly impressive performance can emerge from unintended correlations.
We learned to challenge our own results, compare complex models against simple baselines, and design systems that acknowledge uncertainty.
We also learned that the most valuable applications of AI don't always require full automation.
Following HackHarvard 2026
Our prototype demonstrates the potential of acoustic monitoring, but moving from curated recordings to real barns requires substantially more validation.
Our next priority is testing Oinkalytics with continuous, real-world barn audio across different facilities, microphones, breeds, and environmental conditions.
We also want to expand beyond general distress classification toward more specific, clinically validated acoustic indicators of respiratory disease and other welfare concerns.
That means collaborating with farmers and veterinarians, collecting longitudinal audio data, and evaluating whether acoustic alerts can consistently provide useful warning before conventional observation.
Over time, we envision Oinkalytics becoming an accessible precision livestock monitoring platform that supports both small family farms and large agricultural operations.
The potential impact extends beyond animal welfare.
Every preventable livestock loss also represents resources already consumed: feed, water, land, energy, labor, and associated emissions.
Earlier detection enables more timely intervention, and therefore reduces animal suffering, avoids preventable economic losses, and improves the resource efficiency of livestock production.
Our vision is a future with healthier animals, less suffering, less waste, and more sustainable farming. Because somewhere, an animal is crying out, just imagine a world where someone always hears it.
That's the world we're building with Oinkalytics.
[^1]: Norton et al. (2019). [^2]: Exadaktylos et al. (2008).
Built With
- anthropic-claude
- css3
- fastapi
- ffmpeg
- gradio
- html5
- imessage
- javascript
- kagglehub
- librosa
- machine-learning
- matplotlib
- node.js
- numpy
- openrouter
- pandas
- perch-2.0
- photon
- python
- scikit-learn
- spectrum-ts
- tensorflow
- typescript
- uvicorn