Librosa melspectrogram times don't match actual times in audio file

后端 未结 1 364
半阙折子戏
半阙折子戏 2021-01-27 17:43

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

1条回答
  •  醉话见心
    2021-01-27 18:09

    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.

    0 讨论(0)
提交回复
热议问题