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.

Problem with spectral_bandwidth having only one frame

See original GitHub issue

Hello folks,

I try to use the librosa library for some library I want to implement, which essentially extracts some features from audio files. These files can be very short (including only one frame when transforming it with say stft)

So I stumpled about some unexpected behaviour when using the spectral_bandwith feature.

Let S be some spectrogram (S[bins][frames]) then the following calls will produce (for me) unexpected output:

res_expected_1 = spectral_bandwidth(sr=sr, S=S) res_expected_2 = spectral_bandwidth(sr=sr, S=S[:,0:2]) res_unexpected = spectral_bandwidth(sr=sr, S=S[:,0:1])

Expected results return for each frame a number. So for res_expected_2 exactly 2 and for res_expected_1 exactly len(S[0]) while res_unexpected produces bin_num results. Which I don’t think is what it is intented to do.

in addition I don’t know why the results are wrapped in an array like [[frames]] instead of just [frames]

I hope someone can help me out a bit; Thanks for your time meanwhile

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Mereepcommented, Apr 12, 2017

@bmcfee I don’t know exactly what I did, but that fixed for me 😉

if freq.ndim == 1:
    squeezed_centroid = np.squeeze(centroid)
    if squeezed_centroid.ndim == 0:
        squeezed_centroid = [squeezed_centroid]
    deviation = np.abs(np.subtract.outer(freq, squeezed_centroid))
0reactions
bmcfeecommented, Apr 13, 2017

Cool, glad it’s working for you.

I think we’ll need a slightly more general solution to handle the instantaneous frequency case properly, but it’ll for sure make it into the next point release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Digital Signal Processing: Sampling Rates, Bandwidth ...
The frame size is the block size divided by sample frequency as shown in Figure 4. ... For example, a bandwidth of 16...
Read more >
Spectral Bandwidth - an overview | ScienceDirect Topics
The bandwidth determines the resolution of a signal. This leads one to consider the problem of how the bandwidth and hence the resolution...
Read more >
The Fundamentals of FFT-Based Signal Analysis and ...
This section describes the problem of spectral leakage, the characteristics of windows, some strategies for choosing windows, and the importance of scaling ...
Read more >
Understanding FFT Overlap Processing Fundamentals
Figure 1a has no overlap, and the incoming signal has a short enough duration (10.5 μs total) that it occupies less than 5...
Read more >
Spectral bandwidth correction with optimal parameters based ...
Abstract. Spectral bandwidth correction is an effective way to obtain the original spectrum. However, the correct selection of optimal parameters used to ...
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