I\'m trying to calculate MFCC coefficients using librosa.feature, but when I plot it using specshow, times on the specshow graph don\'t match the actual times in my audio file>
You should specify the sample rate when using specshow
or librosa.feature.mfcc
. Otherwise 22050 Hz
is assumed. Also, tell librosa, which hop length you have used:
[...]
hop_length = int(WINDOW_HOP * fs)
mel_specgram = librosa.feature.melspectrogram(y[:550], sr=fs,
n_mels=20, hop_length=hop_length,
win_length=int(WINDOW_SIZE * fs))
mfcc_s = librosa.feature.mfcc(S=librosa.power_to_db(mel_specgram), n_mfcc=12, sr=fs)
librosa.display.specshow(mfcc_s, x_axis='s', sr=fs, hop_length=hop_length)
These details are essential for proper visualization and not contained in mfcc_s
.