Skip to main content

Electrical Network Frequency (ENF) analysis and matching tool.

Project description

Hum Catcher

A robust command-line tool for Electrical Network Frequency (ENF) analysis. This tool automates the extraction of ENF signals (mains hum) from audio/video recordings and matches them against historical power grid frequency databases to pinpoint the exact time of recording.

Features

  • Robust Audio Analysis: Uses multi-harmonic combination and STFT signal processing to extract high-quality ENF signals even from noisy audio.
  • Media Support: Supports various audio and video formats.
  • Interactive CSV Import Wizard:
    • Auto-detects delimiters and headers.
    • Supports combined Date/Time columns, separate columns, and Unix timestamps.
    • Interactive timezone configuration (supports automatic detection, zoneinfo, and manual offsets).
    • Handles real-world grid data, including sparse datasets, by resampling to match the audio.
  • Advanced Matching Engine:
    • Dual Backend: Supports NumPy (CPU) and OpenCL (GPU) for accelerated matching.
    • Exhaustive Search: Optional brute-force mode for maximum precision.
    • Approximation: Defaults to a faster decimated search followed by fine-tuning ("coarse-to-fine" strategy).
    • Partial Matching: Configurable filtering for matches that extend beyond available grid data.
  • User Experience:
    • Visualizations: Generates plots comparing the reference and target signals.
    • Progress Feedback: Detailed progress bars for file parsing, resampling, and matching.
    • Graceful Exit: Press q at any safe point to abort operations.

Prerequisites

  • Python: 3.8+ (3.9+ recommended for built-in timezone support).
  • System Tool: FFmpeg must be installed and available in your system PATH for media processing.

Usage

You can run the tool as a python module from the source root:

python -m hum_catcher <media_file> <csv_file> [options]

Arguments

Argument Description
media_file Path to the target media file (audio or video).
csv_file Path to the reference grid frequency CSV file.
-f, --frequency Network frequency (e.g., 50 for EU/Asia, 60 for US). Default: 50.0.
-b, --backend Computation backend: numpy (default) or opencl (requires GPU setup).
-m, --max-matches Number of top matches to display. Default: 10.
-pm, --plot-match Plot the best match result.
-pt, --plot-target Plot the extracted target ENF signal.
-pr, --plot-reference Plot the reference ENF signal from CSV.
-e, --exhaustive Skip approximation steps and perform a exhaustive search (slower but potentially more accurate).
-np, --no-partial Filter out matches that do not fully fit within the grid data duration.

Usage Examples

Analyze Audio Only (No Matching):

python -m hum_catcher evidence.wav -pt

Matching Search:

python -m hum_catcher evidence.wav grid_2025.csv -pm

US Grid Search (60Hz Grid):

python -m hum_catcher recording.mp4 us_grid_data.csv -f 60 -pm

High Performance GPU Search:

python -m hum_catcher large_recording.flac huge_grid_db.csv --backend opencl --exhaustive -pm

The Interactive Wizard

When you start the tool, it analyzes the media file first. Then, it loads the CSV file. Since grid data formats vary wildly, Hum Catcher will ask you to confirm details about the CSV structure in the terminal:

  1. Header & Delimiter: It attempts to sniff the CSV format (,, ;, \t) and header presence.
  2. Column Selection: You will be asked to identify which columns contain the Timestamp and Frequency data.
  3. Time Format: It supports standard date strings (e.g., 2023-10-27 14:30:00) or Unix Timestamps.
  4. Timezone: It attempts to detect timezones from the data. If ambiguous, you can input a region (e.g., Europe/Berlin) or offset (e.g., +0100).

Understanding Results

The output table provides the following customized metrics:

  • START/END (Local/Unix): The calculated timestamp of the recording based on the grid match.
  • CORR (Correlation): Pearson correlation coefficient (0.0 to 1.0). Indicates shape similarity. Higher is better.
  • RMSE: Root Mean Square Error. Indicates magnitude similarity.

Troubleshooting

  • "No ENF signal detected": The recording might be digital silence, too short, or lack conductive electrical hum.
  • OpenCL Errors: If using the opencl backend, ensure you have the correct drivers (CUDA/ROCm/Intel Compute) installed for pyopencl to access your GPU.

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

hum_catcher-0.1.1.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

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

hum_catcher-0.1.1-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file hum_catcher-0.1.1.tar.gz.

File metadata

  • Download URL: hum_catcher-0.1.1.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for hum_catcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b37ac8f7b324bf7a48db0f2debcdb00c697f1ea936aa61d5a41de1c014f3543c
MD5 0f6f9d67d95ccef0966837e22d2246d5
BLAKE2b-256 4dc8f4feadcf8273654c6c961f8b5a871510d7f6ded91f1f44969fdede45a82c

See more details on using hashes here.

File details

Details for the file hum_catcher-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hum_catcher-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for hum_catcher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d719e9d6c04067a62fc5d99be3672d04900a7ec1a0d827ed46b9a9d14c3fff89
MD5 9df366d6334c150f5edb32fee07aeb9f
BLAKE2b-256 08f13dd66b7363ec480ce3c9a27122e1d6d3460dfe2e1100ae2f200f8abc085e

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