frequency-detector
Headless Python library that estimates fundamental frequency in Hz from audio buffers or files. Reports raw Hz plus min / average / max over the analyzed audio. No microphone access, waveform UI, or network I/O.
Install
pip install frequency-detector
From a local checkout:
pip install -e ".[dev]"
Formats: WAV is decoded with the Python standard library. MP3, M4A, and AAC require ffmpeg on your PATH. There is no hard file-size limit.
Quick start
from frequency_detector import analyze_file
result = analyze_file("take.wav")
print(result.frequency) # primary Hz estimate (average of voiced frames)
print(result.min_frequency) # Hz
print(result.average_frequency) # Hz
print(result.max_frequency) # Hz
for frame in result.contour:
if frame.voiced:
print(f"{frame.time:.3f}s {frame.frequency:.2f} Hz")
Analyze a NumPy buffer directly:
import numpy as np
from frequency_detector import analyze
sr = 22050
t = np.arange(sr) / sr
tone = 0.4 * np.sin(2 * np.pi * 440.0 * t)
result = analyze(tone, sample_rate=sr)
assert abs(result.average_frequency - 440.0) < 3.0
CLI
frequency-detector take.wav
frequency-detector take.mp3 --json --contour
frequency-detector long.wav --no-max-duration
frequency-detector take.wav --frame-size 2048 --hop-size 512
Analysis window and long files
By default the library analyzes the first 120 seconds of a file. Override it:
| API | Behavior |
|---|---|
max_duration=120 (default) |
Cap at two minutes |
max_duration=None |
No duration cap |
CLI --no-max-duration or --max-duration 0 |
No duration cap |
The analysis frame size and hop size are also configurable (frame_size, hop_size).
Tips for better results
- Prefer monophonic, relatively dry recordings (one voice or one instrument). Full mixes confuse time-domain detectors.
- WAV / higher bitrates usually read cleaner than heavily compressed audio.
- Quiet rooms and less reverb yield more voiced frames.
Public API
| Symbol | Role |
|---|---|
analyze_file(path, **opts) -> FrequencyResult |
Analyze a file on disk |
analyze_buffer(samples, sample_rate, **opts) -> FrequencyResult |
Analyze a PCM array |
analyze(source, **opts) -> FrequencyResult |
File path, bytes, stream, or NumPy array |
FrequencyResult |
Contour + Hz summary (frequency, min_frequency, average_frequency, max_frequency) |
FrequencyFrame |
time, frequency |
Optional note-name helpers live in frequency_detector.notes and are not part of the primary API.
Algorithm: YIN (time-domain), after De Cheveigné & Kawahara (2002).
Development
pip install -e ".[dev]"
pytest
License
MIT © Sherotree
Metadata
Release files for frequency-detector 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| frequency_detector-0.1.0.tar.gz | 13.4 kB | Without provenance | Details for frequency_detector-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| frequency_detector-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for frequency_detector-0.1.0-py3-none-any.whl |
Total release size: 28.1 kB
Release files / frequency_detector-0.1.0.tar.gz
| Download URL | frequency_detector-0.1.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7384533f44d980298139abb0a92b8c6d300511df982255e4f2363b52040655de
|
|
BLAKE2b-256 checksum How to use checksums |
18f7d56300169e410fee7bc6862c2f0e952e155ea6876b6a8fe8d8f7cfa91b80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / frequency_detector-0.1.0-py3-none-any.whl
| Download URL | frequency_detector-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0485d8dc601e907b4296b2afb05fc1a48a271d58d58dd57dc7dbbb72bb226b24
|
|
BLAKE2b-256 checksum How to use checksums |
82263355539f0e10298b402ea9d459ec51565c55c02d1acae612b9fba2c5450c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for frequency-detector 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.