question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

librosa.display.specshow does not display the correct time scale

See original GitHub issue

When 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:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
clare228commented, Aug 2, 2021

Thank you for the help and explanation! I tried the first option you suggested and it worked.

0reactions
bmcfeecommented, Aug 2, 2021

Glad to hear. I’ll leave this issue open so we can address it in the next major release.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found