Views
No views yet
torchfcpe == 0.0.4 (PyPI)python tools/fcpe_export.py --out fcpe.onnx
(requires pip install torch torchfcpe)input: audio float32 [1, n_samples, 1] raw mono audio @ 16 kHz
output: f0_hz float32 [1, n_frames, 1] f0 in Hz (0 = unvoiced)n_samples // 160 + 1threshold=0.006 on confidence;
frames with confidence below it are returned as f0=0. Some quiet
frames may also return NaN (internal log(0)) — treat as unvoiced.1import numpy as np
2import onnxruntime as ort
3import librosa
4
5audio, _ = librosa.load("vocal.wav", sr=16_000, mono=True)
6sess = ort.InferenceSession("fcpe.onnx", providers=["CPUExecutionProvider"])
7f0 = sess.run(["f0_hz"], {"audio": audio.astype(np.float32)[None, :, None]})[0]
8f0 = f0[0, :, 0]
9voiced = np.isfinite(f0) & (f0 > 0)
10print(f"voiced: {voiced.sum()}/{len(f0)} frames")1use pitch_core::PitchTracker;
2use pitch_core_onnx::FcpeEstimator;
3
4let est = FcpeEstimator::new("fcpe.onnx")?;
5let mut tracker = PitchTracker::new(est, 48_000, 1024)?;
6for frame in tracker.process(&audio_chunk)? { /* ... */ }1@article{tu2025fcpe,
2 title = {FCPE: A Fast Context-based Pitch Estimation Model},
3 author = {CN\_ChiTu},
4 journal = {arXiv preprint arXiv:2509.15140},
5 year = {2025},
6 url = {https://arxiv.org/abs/2509.15140}
7}MIT LicenseCopyright (c) 2023 CN_ChiTuPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction […]THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY […]
tools/fcpe_export.py applies a small monkey-patch
to torch.stft so the legacy ONNX tracer can handle the complex-typed
output from torchfcpe's mel extractor. The patch wraps the real-tensor
output in a _FakeComplex shim that exposes .real / .imag as
indexed views — semantically equivalent to the original. Numerical
output should match the upstream torchfcpe model bit-for-bit modulo
floating-point rounding in the ORT runtime.