crepe-predictor
A dependency-light reimplementation of CREPE pitch estimation, exported to ONNX for inference without PyTorch.
crepe_predictor.py— the runtime package: framing, Viterbi-decoded pitch prediction from an ONNX session, and Kaldi-compatible (NCCF, pitch) postprocessing, wrapped in aCrepePredictorclass.export_torchcrepe_to_onnx.py— script to (re-)generate the ONNX checkpoints.
Installation
pip install crepe-predictor
Inference only depends on numpy, onnxruntime, and scipy.
Exporting checkpoints additionally requires torch and onnxscript, listed as script dependencies at the top of export_torchcrepe_to_onnx.py.
API
Inference goes through crepe_predictor.CrepePredictor; crepe_predictor.postprocess_pitch is exposed separately for pitch that was produced elsewhere.
CrepePredictor(capacity="full", *, checkpoint=None, onnx_providers=None)
Resolves a checkpoint and opens an ONNX Runtime session for it.
capacity:"tiny","small","medium","large", or"full"— model size, trading accuracy for speed.checkpoint: path to a local.onnxfile. If omitted, the checkpoint matchingcapacityis downloaded and cached under$CREPE_CACHE_DIR,$XDG_CACHE_HOME, or~/.cache/crepe_predictor/checkpoints.onnx_providers: ONNX Runtime execution providers, e.g.["CUDAExecutionProvider", "CPUExecutionProvider"]. Defaults to["CPUExecutionProvider"].
predict(audio, *, viterbi=True, center=True, frame_shift=0.01) -> np.ndarray
Estimates pitch from 16 kHz mono audio, returning an (n_frames, 2) array of (POV, pitch): probability of voicing in [0, 1], and pitch in Hz.
viterbi: decode pitch bins along a Viterbi path enforcing pitch continuity, instead of a per-frame argmax.center: padaudioso each frame is centered on its timestamp.frame_shift: frame spacing in seconds (the hop).
predict_kaldi(audio, *, viterbi=True, center=True, frame_shift=0.01) -> np.ndarray
Same arguments as predict, but returns (n_frames, 2) of (NCCF, pitch), compatible with Kaldi's process-pitch: unvoiced frames are detected with a voicing HMM, pitch is interpolated over them, and POV is converted to an NCCF value. Raises ValueError if no frame is voiced.
postprocess_pitch(pitch) -> np.ndarray
The (POV, pitch) → (NCCF, pitch) conversion predict_kaldi applies, exposed on its own so it can be run over an (n_frames, 2) array obtained from predict earlier or from another pitch extractor.
Usage
Estimate pitch from a synthetic tone:
import numpy as np
from crepe_predictor import CrepePredictor
predictor = CrepePredictor("full") # "tiny", "small", "medium", "large", or "full"
t = np.arange(16000) / 16000 # 1 second at 16 kHz
audio = np.sin(2 * np.pi * 220 * t).astype(np.float32) # a 220 Hz tone
pov, pitch = predictor.predict(audio).T
print(pitch[pov > 0.5]) # pitch in Hz for confidently voiced frames
Process a recording and produce Kaldi-compatible pitch features, running on GPU when available:
from scipy.io import wavfile
from crepe_predictor import CrepePredictor
predictor = CrepePredictor(
"full",
onnx_providers=["CUDAExecutionProvider", "CPUExecutionProvider"],
)
sample_rate, audio = wavfile.read("speech.wav")
assert sample_rate == 16000
audio = audio.astype("float32") / 32768.0 # int16 PCM -> float32 in [-1, 1]
nccf, pitch = predictor.predict_kaldi(audio).T
Metadata
Release files for crepe-predictor 0.2.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 |
|---|---|---|---|---|
| crepe_predictor-0.2.0.tar.gz | 6.4 kB | Without provenance | Details for crepe_predictor-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crepe_predictor-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for crepe_predictor-0.2.0-py3-none-any.whl |
Total release size: 13.1 kB
Release files / crepe_predictor-0.2.0.tar.gz
| Download URL | crepe_predictor-0.2.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
569eec84ca0b04ecf9e22d7b44a4b17994959f6cd7a593c87e50ad7de2c718fd
|
|
BLAKE2b-256 checksum How to use checksums |
590f83ec91cba57a291b38c549abb7b571d177a864fcca4c2cd516bf747f8af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / crepe_predictor-0.2.0-py3-none-any.whl
| Download URL | crepe_predictor-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61907e87cc3ce566973bf90118666db2eb2d17a71ae0d102742b7c5e21b1ca35
|
|
BLAKE2b-256 checksum How to use checksums |
f15e33b09f9db210462fe23e60810e5ba5f92df2873c4d19bc72764b00f56a2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for crepe-predictor 0.2.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.