librosa.display.specshow does not display the correct time scale
See original GitHub issueWhen trying to display a chromagram using librosa.display.specshow, the time scale is not correct. The time scale is correct when the hop_length is its default value (512). However, it is incorrect whenever the hop_length is changed. (The input length increases as I increase the hop_length).
Code I used to generate and plot the chromagram:
# 512 is the default, when this number is altered, the time scale is wrong
HOP_SIZE = 512
y, sr = librosa.load(mp3)
chroma_feature = librosa.feature.chroma_stft(y=y, sr = sr, hop_length = HOP_SIZE)
fig, ax = plt.subplots()
img = librosa.display.specshow(chroma_feature, y_axis='chroma', x_axis='time', ax=ax, sr = sr, hop_length = HOP_SIZE)
fig.colorbar(img, ax=ax)
plt.show()
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
librosa.display.specshow — librosa 0.10.0.dev0 documentation
Sample rate used to determine time scale in x-axis. Number of samples per frame in STFT/spectrogram displays. By default, this will be inferred...
Read more >specshow: fmax, tmax etc. options don't affect conventional ...
I'm plotting a spectrogram using librosa.display.specshow. I want to zoom in on the first 5 seconds, and the frequencies up to 2 kHz....
Read more >Matplotlib not showing librosa specshow in custom class ...
The problem seems to come from the fact that you use matplotlib.figure which is not managed by pyplot . Changing the import works...
Read more >librosa.display.specshow — librosa 0.6.0 documentation
Sample rate used to determine time scale in x-axis. ... Range for the x- and y-axes. Valid types are: None, 'none', or 'off'...
Read more >Python Visualization - International Audio Laboratories Erlangen
Furthermore, we use the function librosa.display.specshow to visualize the spectrogram Y, where the magnitude values are converted to a decibel scale and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for the help and explanation! I tried the first option you suggested and it worked.
Glad to hear. I’ll leave this issue open so we can address it in the next major release.