carat.annotations.load_beats¶
-
carat.annotations.
load_beats
(labels_file, delimiter=', ', times_col=0, labels_col=1)[source]¶ Load annotated beats from text (csv) file.
Parameters: - labels_file : str
name (including path) of the input file
- delimiter : str
string used as delimiter in the input file
- times_col : int
column index of the time data
- labels_col : int
column index of the label data
Returns: - beat_times : np.ndarray
time instants of the beats
- beat_labels : list
labels at the beats (e.g. 1.1, 1.2, etc)
Notes
It is assumed that the beat annotations are provided as a text file (csv). Apart from the time data (mandatory) a label can be given for each beat (optional). The time data is assumed to be given in seconds. The labels may indicate the beat number within the rhythm cycle (e.g. 1.1, 1.2, or 1, 2).
Examples
Load an included example file from the candombe dataset. http://www.eumus.edu.uy/candombe/datasets/ISMIR2015/
>>> annotations_file = carat.util.example_beats_file(num_file=1) >>> beats, beat_labs = annotations.load_beats(annotations_file) >>> beats[0] 0.548571428 >>> beat_labs[0] '1.1'
Load an included example file from the samba dataset. http://www.smt.ufrj.br/~starel/datasets/brid.html
>>> annotations_file = carat.util.example_beats_file(num_file=2) >>> beats, beat_labs = annotations.load_beats(annotations_file, delimiter=' ') >>> beats array([ 2.088, 2.559, 3.012, 3.48, 3.933, 4.41, 4.867, 5.32, 5.771, 6.229, 6.69, 7.167, 7.633, 8.092, 8.545, 9.01, 9.48, 9.943, 10.404, 10.865, 11.322, 11.79 , 12.251, 12.714, 13.167, 13.624, 14.094, 14.559, 15.014, 15.473, 15.931, 16.4, 16.865, 17.331, 17.788, 18.249, 18.706, 19.167, 19.643, 20.096, 20.557, 21.018, 21.494, 21.945, 22.408, 22.869, 23.31 , 23.773, 24.235, 24.692, 25.151, 25.608, 26.063, 26.52 ])
>>> beat_labs ['1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2', '1', '2']