You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.2.


librosa.blocks_to_time(blocks, block_length, hop_length, sr)[source]

Convert block indices to time (in seconds)


Block index or array of block indices

block_lengthint > 0

The number of frames per block

hop_lengthint > 0

The number of samples to advance between frames

srint > 0

The sampling rate (samples per second)

timesnp.ndarray [shape=samples.shape]

The time index or indices (in seconds) corresponding to the beginning of each provided block.

Note that these correspond to the time of the first sample in each block, and are not frame-centered.


Get time indices for each block in a stream

>>> filename = librosa.ex('brahms')
>>> sr = librosa.get_samplerate(filename)
>>> stream =, block_length=16,
...                         frame_length=2048, hop_length=512)
>>> for n, y in enumerate(stream):
...     n_time = librosa.blocks_to_time(n, block_length=16,
...                                     hop_length=512, sr=sr)