librosa.output.times_csv

librosa.output.times_csv(path, times, annotations=None, delimiter=’, , fmt=’%0.3f’)[source]

Save time steps as in CSV format. This can be used to store the output of a beat-tracker or segmentation algorithm.

If only times are provided, the file will contain each value of times on a row:

times[0]\n
times[1]\n
times[2]\n
...

If annotations are also provided, the file will contain delimiter-separated values:

times[0],annotations[0]\n
times[1],annotations[1]\n
times[2],annotations[2]\n
...
Parameters:
path : string

path to save the output CSV file

times : list-like of floats

list of frame numbers for beat events

annotations : None or list-like

optional annotations for each time step

delimiter : str

character to separate fields

fmt : str

format-string for rendering time

Raises:
ParameterError

if annotations is not None and length does not match times

Examples

Write beat-tracker time to CSV

>>> y, sr = librosa.load(librosa.util.example_audio_file())
>>> tempo, beats = librosa.beat.beat_track(y, sr=sr, units='time')
>>> librosa.output.times_csv('beat_times.csv', beats)