Clip long gunshot audio samples into single or windowed audio clips
Project description
GSClipper: A naive gunshot audio parser to generate stand-alone clips
Clip long gunshot audio samples into single or windowed audio clips.
Prerequisites
- Python 3.12 runtime
- Pip for package installation
Installation
Install the dependencies into the environment with pip:
pip install -r requirements.txt
Usage
Picking an Extractor
This library offers three different methods for identifying candidate gunshots, each developed when the previous one failed on a new use case.
To process somewhat "dirty" audio, the SpectrumGunshotExtractor may work well. It has been tested on these datasets to great effect:
For various reasons, the SpectrumGunshotExtractor did not work well on a dataset derived from the Free Firearm Sounds Library, nor our own initial field data. For those datasets, the AmplitudeGunshotExtractor was developed. It picks up about 99.9% of gunshots from the FFS library, but fails on many Cadre Forensics samples.
The ImpulseGunshotExtractor was added to fix shortcomings with the AmplitudeGunshotExtractor on certain live data, particularly:
- Windy days where the audio levels vary widely for the same platform/cartridge at the same mic over time
- Quieter platform/cartridge combinations (e.g., .22 LR or suppressed rounds)
Initial testing has shown the latter to be the most robust in the most circumstances, but no extraction method will be 100% accurate.
Preprocessing
A distinctive feature of gunshots relative to other sounds, even ones very loud in the time domain, is that they have significant high-frequency components. Compare the spectra of the same data before and after high-pass filtering:
Raw Data
High-Pass Filtered Data
Existing Preprocessors
Currently only a high-pass filter (HPFilter) is available. The parameters in examples/compare.py work well in most cases.
Post Processing
Real-world data will almost never be clean enough to automatically extract gunshots with perfect precision and recall. Setting extractor parameters too "tight" will lower recall and "leave data on the table." Conversely, setting them too leniently will allow incorrectly-labeled data into the dataset.
Post-processors allow a semi-automatic method for flagging potentially problematic data. They can be operated in two modes: PRUNE to automatically remove any potentially problematic data, and FLAG to provide a "vote of no confidence" on an extracted clip. The provided post-processors have unique strengths and weaknesses that are not easy to identify for a dataset a priori, and they often do not perfectly agree. Applying the post-processors as shown in examples/compare.py to a recent live dataset produced the following results:
| Votes | Count |
|---|---|
| 0 | 4914 |
| 1 | 341 |
| 2 | 651 |
| 3 | 383 |
| 4 | 345 |
Again, you will need to balance your requirements for precision and recall carefully.
Examples
You can run the examples/compare.py script to ... compare ... the results of the extractors on live data collected under various conditions. The files in audio/ come from three sources:
cadre-*.wav: Cadre Forensics dataset (see above)ffs-*.wav: Free Firearm Sounds Library (see above)- Everything else was collected by Certus Innovations
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Ryan Quinn - Initial work
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gsclipper-0.5.1.tar.gz.
File metadata
- Download URL: gsclipper-0.5.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
687c6b1b40143ef27dbb9a96feb897bfa57e94fa5e6e0d0ed550f1df332b6cdc
|
|
| MD5 |
3ab3b1b11793a3f3efd877398cb737bf
|
|
| BLAKE2b-256 |
a3fa6037993e86314edaf6613f64d5914b3ead36ef8b5354768ff77fec2e6973
|
File details
Details for the file gsclipper-0.5.1-py3-none-any.whl.
File metadata
- Download URL: gsclipper-0.5.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50313db30aea52c457e3a23c8ce096f43d17ef4c93aafc56c5fd55127057f3fc
|
|
| MD5 |
3eecee937381aa193c2bedf012e623a2
|
|
| BLAKE2b-256 |
31e910bcfbe6ff8e9869c61c1522c34392d4b8b885235fbc95a8df584e818115
|