Skip to main content

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

Raw Data

High-Pass Filtered Data

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsclipper-0.5.3.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gsclipper-0.5.3-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file gsclipper-0.5.3.tar.gz.

File metadata

  • Download URL: gsclipper-0.5.3.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

Hashes for gsclipper-0.5.3.tar.gz
Algorithm Hash digest
SHA256 395b733a16b8eef1a79a05d131d257ffbf71348951145d95d92ae07649e7e66f
MD5 db54a9a68b58d9a8dde4a8035eb28bc1
BLAKE2b-256 df4f6aee26e6f6cadc70614ba51ab732d02568cc270e40c9671024cf08117286

See more details on using hashes here.

File details

Details for the file gsclipper-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: gsclipper-0.5.3-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

Hashes for gsclipper-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a1b4aab51ee8031a0991ff5c411cfaa04dc9ff0d984c3ec33f9b8d8e639c56
MD5 afeed981bcd1594d79869c20cb83cd49
BLAKE2b-256 15a30f95d23f5b30609fa7ddb0d6ef485d561a6f15d8b95e39f39bb31e32bd80

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.3 This release

2 files

0.5.2

2 files

0.5.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page