Skip to content

ENH: Remove signal.spectrogram, replace with vocalpy.spectrogram #88

Closed

Description

@NickleDave
  • The signal.spectrogram code is ... not great (speaking as the author). In example snippets we log transform to visualize as a very crude sort of map to dB
  • Ideally there should be a way to get a Spectrogram by default from some function that looks good. Ofc "looks good" depends on parameters and these can vary depending on species. But seems like we can offer "good enough" for now.
  • Librosa.stft provides better looking spectrograms by default, but for someone who does not think DSP natively (e.g., moi) it is not intuitive to have to do the steps of stft -> amplitude_to_db(np.abs(S))

So I think we should:

  • remove signal.spectrogram
  • add a function vocalpy.spectrogram or spect_from_audio that gives back a Spectrogram from an Audio
    • basically a wrapper around librosa.stft
    • that does the stft -> amplitude_to_db(np.abs(S)) step
    • that additionally uses other librosa helper functions to get times and frequencies for the vocalpy.Spectrogram
    • and of course in the docstring we should point out it's just a wrapper around these functions and ask people to cite librosa

... I'm unsure about whether I want to keep the spectrogram namespace to put other things in or if I want to prefer a flatter namespace. The whole point of this will be to make it as easy as possible to get a vocalpy.Spectrogram to visualize, so I think we should go with flat. The other things I would put in a spectrogram namepsace would be other ways of computing spectrograms, e.g. multi-taper, time-freq replacement, whatever sigsound does (fancy Theunissen thing I am as yet too dumb to understand). But I think those make more sense in the spectral module

Activity

  1. NickleDave commented on Dec 27, 2023

    @NickleDave
    ContributorAuthor

    We should have a parameter like transform that can be either a string or a callable

  2. added 2 commits that reference this issue on Dec 30, 2023
    1f64a85
    5c0e11f
  3. added
    Spectrogram
    on Dec 30, 2023
  4. added 2 commits that reference this issue on Jan 5, 2024
    12e4f84
    6d17821
  5. added 2 commits that reference this issue on Jan 17, 2024
    96ab0fc
    ea86d2a
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

    Spectrogram

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions