How do I get beat timestamps out of a music track with librosa so I can place cuts, and what does beat_track actually do and return?
Problem: an editor or agent wants beat times (seconds) from a track to place cuts or markers. Conditions: a single audio file with a reasonably steady pulse; Python with librosa. Method: librosa.beat.beat_track follows Ellis's dynamic-programming tracker in three stages (onset strength, tempo estimate from onset correlation, peak picking consistent with that tempo). Call it with y/sr or a precomputed onset_envelope, and pass units='time' to get seconds rather than frame indices (frames are the default; hop_length defaults to 512 samples). Defaults visible in the source: start_bpm=120.0 (initial tempo guess), tightness=100 (how strongly beats must follow the tempo), trim=True (drops leading/trailing beats with weak onsets). You can supply bpm= to skip estimation, or prior= (a scipy distribution over tempo) which makes start_bpm ignored. The returned tempo is an ndarray even for mono input. Example (inference): at 24 fps and 120 BPM a beat is 0.5 s = 12 frames, so round beat times to ...
Structured fields
{
"citations": [
{
"url": "https://raw.githubusercontent.com/librosa/librosa/main/librosa/beat.py",
"note": "beat_track docstring; beat_track parameters; beat_track Returns; beat_track signature"
}
]
}Evidence claims
- [sourced_fact] Problem: an editor or agent wants beat times (seconds) from a track to place cuts or markers. Conditions: a single audio file with a reasonably steady pulse; Python with librosa. Method: librosa.beat.beat_track follows Ellis's dynamic-programming tracker in three stages (onset strength, tempo estimate from onset correlation, peak picking consistent with that tempo). Call it with y/sr or a precomputed onset_envelope, and pass units='time' to get seconds rather than frame indices (frames are the default; hop_length defaults to 512 samples). Defaults visible in the source: start_bpm=120.0 (initial tempo guess), tightness=100 (how strongly beats must follow the tempo), trim=True (drops leading/trailing beats with weak onsets). You can supply bpm= to skip estimation, or prior= (a scipy distribution over tempo) which makes start_bpm ignored. The returned tempo is an ndarray even for mono input. Example (inference): at 24 fps and 120 BPM a beat is 0.5 s = 12 frames, so round beat times to the nearest frame only after choosing the project frame rate. Failure modes: the tracker assumes one dominant tempo; if there is no detectable onset strength it returns 0 BPM and an empty beat list, so check for that before cutting. Limitations: docstrings describe parameters but give no accuracy numbers; this is the main-branch source on the fetch date, so signatures may differ in older installs. Version/date: librosa main branch, fetched 2026-10-23. · locator: beat_track docstring; beat_track parameters; beat_track Returns; beat_track signature source
Rights
| component | license | hosting | redistribution | modification | training | Evidence and notes |
|---|---|---|---|---|---|---|
| documentation | unknown | permitted | permitted | unknown | unknown | Applies to this original summary only, not to the cited sources. |