Skip to content

BUG: VS code jupyter notebook kernel crashing when calling feature.sat (specifically, spectral.sat._sat_multitaper) #222

Open

Description

@eintzandt

I am running vocalpy (version 0.10.2) in a vocalpy conda environment in a jupyter notebook using VS code. My notebook code is as follows:

from vocalpy import feature
from vocalpy import Sound
import numpy as np

data = np.load("filename.npy")
fs = 125000
n_fft=512
hop_length = 256

features = feature.sat(Sound(data, fs), n_fft=n_fft, hop_length=hop_length)

I went to the _sat.py file and put print statements throughout so I could figure out where the script is crashing. That isolated it to:
power_spectrogram, spectra1, spectra2 = spectral.sat._sat_multitaper(
sound, n_fft, hop_length
)

So I put print statements in sat.py in the _sat_multitaper function, and I think the cause of the crash is:
windows = librosa.util.frame(
audio_pad, frame_length=n_fft, hop_length=hop_length
)

This librosa function runs in my notebook, so I'm not sure exactly why it's crashing inside the vocalpy function.

Thank you!

Error message:
"The Kernel crashed while executing code in the current cell or a previous cell.
Please review the code in the cell(s) to identify a possible cause of the failure.
Click here for more info.
View Jupyter log for further details."

Activity

  1. eintzandt commented on Sep 29, 2025

    @eintzandt
    Author

    I downgraded vocalpy to version 0.9.3 and now feature.sat.similarity_features() runs fine in my notebook

  2. NickleDave commented on Sep 29, 2025

    @NickleDave
    Contributor

    Hi @eintzandt sorry you're running into this issue -- thank you for the detailed error report.

    I see you have a relatively high sampling rate, my guess is you are working with rodent data?
    Are you by any chance able to share the file that causes the crash?
    Either by replying to this and attaching it in a zip, or by sharing via email (nicholdav at gmail).
    Would be great if I could "borrow" that little bit of data to reproduce the bug locally.

    I think what's going on here is that this code was originally developed for zebra finch calls and song, so it works fine for brief clips sampled at 32kHz, but it hasn't been tested extensively (yet, except by you 😅 ) for other animal sounds.

    I think you've already figured this out, but: my guess is you're hitting an out-of-memory error when librosa tries to make an array of sliding windows out of your audio clip. (That's what librosa.util.frame does). And that's when the kernel crashes.
    Basically: you have a lot of samples, so you end up with a ton of frames.

    If you're able to break the sound up into smaller clips, that might be one way to get it to work?
    E.g., using vocalpy.segment.ava or something like that, if you're not already.

    I need to check, but I think the older version might "work" by accident, because it's not computing one or two features that are particularly computationally expensive (even for short zebra finch calls), that rely on frame.

    Not sure I'll have time to look into this today but I can see if I can get you more details by mid-week.
    I don't have a ton of time to re-engineer vocalpy.features.sat right now but maybe we could run on a single window at a time so we don't get the OOM error? That's my first idea but I need to stare at the internals again to see.

    Let's see if we can get this to work for your use case too.

  3. NickleDave commented on Oct 20, 2025

    @NickleDave
    Contributor

    Hi @eintzandt just checking back on this -- any chance you could share the audio file that caused the crash so I can reproduce and fix?

  4. eintzandt commented on Oct 24, 2025

    @eintzandt
    Author
  5. NickleDave commented on Oct 25, 2025

    @NickleDave
    Contributor

    Thank you @eintzandt much appreciated! (I'm sure you are busy with other stuff)

    Will bump this up the to-do list and see if I can figure out what's causing the crash in the current version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions