Skip to main content

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

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.

Project details


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.2.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.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gsclipper-0.5.2.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.2.tar.gz
Algorithm Hash digest
SHA256 73f230f43493506abceca7430cb48a6ce1835f98df0dbb31cc6818cf974e7f7e
MD5 5995b5cec632f874a48f40e626d39d25
BLAKE2b-256 e32c02883553d3c602521bec53361a20de5bc967829ab01b7eadd33406bce0c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gsclipper-0.5.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 43235606b043a1fbde5247f90aaa7cd018b99751f0f040c41c146390485adae9
MD5 8f415a7c325219686f15f3188529d8b0
BLAKE2b-256 a99cac55005ffaa18809db95b626fa2f8e3142ecb9ee18f31a6837baa627526f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page