Caution
You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.9.1.
librosa.core.times_like¶
- librosa.core.times_like(X, sr=22050, hop_length=512, n_fft=None, axis=- 1)[source]¶
Return an array of time values to match the time axis from a feature matrix.
- Parameters
- Xnp.ndarray or scalar
If ndarray, X is a feature matrix, e.g. STFT, chromagram, or mel spectrogram.
If scalar, X represents the number of frames.
- srnumber > 0 [scalar]
audio sampling rate
- hop_lengthint > 0 [scalar]
number of samples between successive frames
- n_fftNone or int > 0 [scalar]
Optional: length of the FFT window. If given, time conversion will include an offset of n_fft / 2 to counteract windowing effects when using a non-centered STFT.
- axisint [scalar]
The axis representing the time axis of X. By default, the last axis (-1) is taken.
- Returns
- timesnp.ndarray [shape=(n,)]
ndarray of times (in seconds) corresponding to each frame of X.
See also
samples_like
Return an array of sample indices to match the time axis from a feature matrix.
Examples
Provide a feature matrix input:
>>> y, sr = librosa.load(librosa.util.example_audio_file()) >>> X = librosa.stft(y) >>> times = librosa.times_like(X) >>> times array([ 0.00000000e+00, 2.32199546e-02, 4.64399093e-02, ..., 6.13935601e+01, 6.14167800e+01, 6.14400000e+01])
Provide a scalar input:
>>> n_frames = 2647 >>> times = librosa.times_like(n_frames) >>> times array([ 0.00000000e+00, 2.32199546e-02, 4.64399093e-02, ..., 6.13935601e+01, 6.14167800e+01, 6.14400000e+01])