/BeatNetLite

Offline beat, downbeat, tempo, and meter tracking system

Primary LanguagePythonCreative Commons Attribution 4.0 InternationalCC-BY-4.0

This is an inference-only, offline-only implementation of BeatNet, a SOTA joint beat, downbeat, tempo, and meter tracking system. This implementation is focused on minimizing the dependencies needed to run BeatNet end to end. You only need:

  • torch (for running the pretrained BeatNet CRNNs)
  • librosa (0.11.0 or newer) for feature extraction

In particular, this implementation doesn't depend on madmom. The downbeat post-processing is using a numba-accelerated downbeat tracker that mimics madmom's DBN. Other trackers (e.g. particle filter) have been removed.

End to end run time (CPU only) is about 2 to 4 seconds for a 3 minute song (faster on second run due to numba JIT).

Usage:

from BeatNetLite import BeatNetLite

af = "song.wav"

bn = BeatNetLite(1) # 1 = generic model
grid = bn.process(af)

print(grid)

The output is a JSON object, which maps time in seconds to the beat number:

{
  "0.02": 3,
  "0.42": 4,
  "0.86": 1,
  "1.28": 2,
  "1.7": 3,
  "2.14": 4,
  "2.56": 1,
  "3.0": 2,
  "3.42": 3,
  "3.84": 4,
  // etc.
}