Abstract
Urban gunfire often goes unreported, and commercial detection systems are prohibitively expensive for many cities. This paper explores a low-cost ($150) alternative utilizing a Raspberry Pi 3 B+ and an ensemble of Convolutional Neural Networks (CNNs). By processing audio chunks through a majority-rules ensemble of 1D and 2D CNNs, the system achieves over 99% accuracy in identifying gunshots while effectively filtering out common distractors like fireworks. This edge-computing solution offers a scalable, autonomous path for enhancing public safety.
Introduction
The "reporting gap" in urban gunfire is a significant challenge for law enforcement, with studies indicating that up to 80% of incidents are never reported to emergency services. While commercial solutions like ShotSpotter exist, their high annual costs—often reaching $90,000 per square mile—limit their accessibility. This research aims to democratize public safety technology by developing an autonomous, high-accuracy gunshot detection system using off-the-shelf hardware. The goal is to transition from expensive, centralized infrastructure to a distributed network of inexpensive microcomputers capable of real-time SMS alerting.
System Architecture and Methods
The proposed system utilizes a Raspberry Pi 3 B+ equipped with a USB microphone and an SMS modem. The software pipeline, orchestrated in Python, continuously captures audio in two-second segments. These segments are analyzed by a majority-rules ensemble of three distinct CNN architectures:
- 1D CNN: Processes raw audio time-series data.
- 2D CNN (128x64): Analyzes visual spectrograms of the audio.
- 2D CNN (128x128): Analyzes higher-resolution spectrograms.
By requiring at least two models to agree on a classification, the system significantly reduces false positives. To accommodate the Raspberry Pi's limited resources, the models were optimized using TensorFlow Lite (TFLite) for quantization and compression.
Datasets and Training
The researchers compiled a dataset of over 14,000 audio clips from public databases (Freesound, SoundBible), custom lab recordings, and live-fire gun ranges. To prevent overfitting and improve robustness, a Generative Adversarial Network (GAN) was used to synthesize additional gunshot samples. After data augmentation—including time shifting, pitch adjustments, and background noise injection—the final training set comprised over 90,000 segments. The "Other" category included challenging distractors such as fireworks, sirens, and jackhammers.
Results and Discussion
The CNN ensemble achieved a validation accuracy of 99.5%, with high precision (97.9%) and recall (98.0%). A critical success was the system's ability to distinguish gunshots from fireworks, achieving 99.8% precision in this specific comparison.
Key insights from the development process include:
- Ensemble Synergy: The 1D model acted as a "safety net," excelling at classifying specific background noises where 2D models occasionally struggled.
- Field Data Necessity: Models trained solely on "clean" recordings underperformed in real-world environments. Retraining on site-specific audio was crucial for maintaining high recall.
- Edge Optimization: TFLite was essential for memory management, though it introduced a slight latency trade-off during model loading.
Conclusion and Future Work
This study demonstrates that a high-performing gunshot detection system can be built for approximately $150. While the current prototype is effective up to 225 meters, future work will focus on localization using Time Difference of Arrival (TDOA) with arrays of synchronized units. Additional improvements include solar power integration for sustainable urban deployment and further testing in complex "urban canyon" environments to account for acoustic reflections.
Summary updated