Skip to content

collection of pitch (f0, fundamental frequency) detection algorithms with unified interface

Notifications You must be signed in to change notification settings

tandav/pitch-detectors

Repository files navigation

pipeline status

pitch-detectors

collection of pitch (f0, fundamental frequency) detection algorithms with unified interface

list of algorithms

algorithm cpu gpu MDBStemSynth accuracy Mir1K accuracy
Crepe 0.886 ± 0.059 0.759 ± 0.073
Penn 0.699 ± 0.263 0.660 ± 0.090
PipTrack 0.524 ± 0.286 0.864 ± 0.071
PraatAC 0.777 ± 0.302 0.859 ± 0.074
PraatCC 0.776 ± 0.300 0.872 ± 0.068
PraatSHS 0.534 ± 0.238 0.578 ± 0.169
Pyin 0.722 ± 0.252 0.888 ± 0.047
Rapt 0.791 ± 0.282 0.827 ± 0.078
Reaper 0.792 ± 0.261 0.795 ± 0.083
Spice 0.024 ± 0.034 0.889 ± 0.046
Swipe 0.784 ± 0.276 0.796 ± 0.062
TorchCrepe 0.764 ± 0.273 0.774 ± 0.084
TorchYin 0.735 ± 0.268 0.866 ± 0.052
World 0.869 ± 0.135 0.842 ± 0.075
Yaapt 0.740 ± 0.271 0.744 ± 0.107
Yin 0.749 ± 0.269 0.884 ± 0.043

accuracy is mean raw pitch accuracy

install

pip install pitch-detectors

All agorithms tested on python3.12, this is recommended python version to use

usage

from scipy.io import wavfile
from pitch_detectors import algorithms
import matplotlib.pyplot as plt

fs, a = wavfile.read('data/b1a5da49d564a7341e7e1327aa3f229a.wav')
pitch = algorithms.Crepe(a, fs)
plt.plot(pitch.t, pitch.f0)
plt.show()

Alt text Colab notebook with plots for all algorithms/models

additional features

  • robust (vote + median) ensemble algorithm using all models
  • json import/export

notes:

Tests are running in subprocess (using scripts/run_algorithm.py) to avoid pytorch cuda import caching. It's difficult to disable gpu after it has been initialized. (pytorch/pytorch#9158) It is also difficult to set correct PATH and LD_LIBRARY_PATH without a subprocess.