Real-time cat sound recognition on Raspberry Pi 5
A 4-class cat sound classifier (meow / purr / yowl / other) that runs on-device using TFLite, trained with MobileNetV2 transfer learning on Mel-spectrogram images.
| Label | Description |
|---|---|
meow |
Standard meow calls (including hungry / happy variants) |
purr |
Continuous low-frequency purring |
yowl |
Intense vocalizations (yowl + high-quality growl samples) |
other |
Background noise / silence |
- Base model: MobileNetV2 (ImageNet pre-trained, frozen in Phase 1)
- Input: 128Γ128Γ3 Mel-spectrogram images (1-second audio clips)
- Output: 4-class softmax
- Two-phase training: Phase 1 β train head (10 epochs, lr=1e-3); Phase 2 β fine-tune top 30 layers (40 epochs, lr=1e-4)
- Runtime: TFLite (
cat_sound.tflite, ~9.8 MB)
data/raw/ β scripts/02_preprocess.py
β data/features/ (X.npy, y.npy, dataset.csv)
β scripts/03_train.py
β models/best_model.keras
β scripts/04_convert_tflite.py
β models/cat_sound.tflite
β pi5/pi5_inference.py (on Raspberry Pi 5)
pip install -r requirements.txtPlace .mp3 / .wav files in:
data/raw/
meow/
purr/
yowl/
background/
growl/ β optional, merged into yowl
python scripts/filter_growl.py --dry-run # preview
python scripts/filter_growl.py --keep 15 # archive low-quality growlpython scripts/02_preprocess.pypython scripts/03_train.pypython scripts/04_convert_tflite.pyscp models/cat_sound.tflite pi5/pi5_inference.py user@<pi-ip>:~/catmow/python pi5_inference.pyFeatures:
- 3-level VAD pre-filter (RMS energy / cat-band ratio / spectral flatness)
- Per-class confidence thresholds (meow=0.60, purr=0.55, yowl=0.88, other=0.50)
- Event-based debounce with sustain + cooldown
- Emoji output + confidence display
data/processed/ contains segmented and augmented audio clips (.mp3):
| Directory | Contents |
|---|---|
growl/ |
15 high-quality growl clips (spectral-filtered) |
growl_excluded/ |
16 archived low-quality growl clips |
hiss/ |
31 hiss clips (not used in training β spectral overlap with purr) |
yowl/ |
11 long-form yowl recordings |
purr/ |
~62 purr recordings |
meow/ |
Meow + hungry + happy clips |
background/ |
Background noise clips |
| Class | Test Accuracy |
|---|---|
| meow | 91.3% |
| purr | 46.0% |
| yowl | 82.6% |
| other | 2.5% |
| Overall | 75.0% |
Val accuracy: 86.5% β purr test set is small (74 samples from original distribution) and not representative of real-world diversity.
- Purr: training data mostly from YouTube videos β limited diversity. Recording from real cats in different conditions would significantly improve recall.
- other class: near-zero test accuracy; needs more varied background noise types.
- Meow/Yowl boundary: some confusion remains, especially with tonal meow variants.
MIT