torchcrepe (ONNX)
ONNX export of maxrmorrison/torchcrepe, a PyTorch implementation of CREPE (Kim et al., 2018), a convolutional neural network for monophonic fundamental frequency (F0) / pitch estimation directly from the raw waveform.
This is an unmodified re-export of the upstream tiny/full checkpoints โ same weights, same
architecture, only the serialization format changes. It is the same conversion already used in
production by superassp, an R package for acoustic phonetic analysis.
Files
| File | Precision | Size | Notes |
|---|---|---|---|
onnx/tiny.onnx |
fp32 | 1.96 MB | recommended |
onnx/tiny_fp16.onnx |
fp16 | 1.00 MB | 95.6% bin agreement vs fp32 |
onnx/tiny_int8.onnx |
int8 (dynamic) | 0.52 MB | 82.7% bin agreement vs fp32 |
onnx/full.onnx |
fp32 | 89.0 MB | recommended |
onnx/full_int8.onnx |
int8 (dynamic) | 22.3 MB | 78.8% bin agreement vs fp32, experimental |
full_fp16.onnx is intentionally not included โ naive fp16 casting broke the full model
(only 37.8% pitch-bin agreement with fp32 on the validation audio; see CONVERSION_REPORT.md).
Use full.onnx (fp32) or, if size matters more than accuracy, full_int8.onnx.
I/O spec
input: "frames" float32 [num_frames, 1024] # one 1024-sample @16kHz window per row
output: "probabilities" float32 [num_frames, 360] # sigmoid activation per pitch bin, pre-decode
Framing and decoding are not part of the graph โ you must do these yourself, exactly as the
original torchcrepe package does in Python:
- Resample audio to 16 kHz mono.
- Slice into overlapping 1024-sample windows (default hop 160 samples = 10ms).
- Run the model to get a
[num_frames, 360]activation matrix. - Decode each row to a pitch: convert the argmax (or weighted-argmax, or Viterbi-smoothed) bin
index to cents (
cents = 20 * bin + 1997.3794084376191) then to Hz (hz = 10 * 2^(cents/1200)). - Use the activation at the chosen bin as a periodicity/confidence score for voicing decisions.
See maxrmorrison/torchcrepe's decode.py and convert.py for the exact reference math.
Quick start (Python, onnxruntime)
import numpy as np
import onnxruntime as ort
sess = ort.InferenceSession("onnx/full.onnx", providers=["CPUExecutionProvider"])
frames = np.zeros((1, 1024), dtype=np.float32) # replace with real 16kHz windows
(probabilities,) = sess.run(None, {"frames": frames})
bins = probabilities.argmax(axis=1)
cents = 20 * bins + 1997.3794084376191
hz = 10 * 2 ** (cents / 1200)
Validation
Re-exported directly from the upstream .pth checkpoints, opset 17. Verified numerically
identical (max abs diff ~1e-6, float32 noise floor) to the original PyTorch model, and
byte-for-byte identical inference output to the crepe.onnx files already deployed in
superassp. Full methodology and quantization drift numbers in CONVERSION_REPORT.md.
License
MIT, inherited from upstream maxrmorrison/torchcrepe. Please cite:
@inproceedings{kim2018crepe,
title={Crepe: A convolutional representation for pitch estimation},
author={Kim, Jong Wook and Salamon, Justin and Li, Peter and Bello, Juan Pablo},
booktitle={2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
pages={161--165},
year={2018},
organization={IEEE}
}