spafe: Simplified Python Audio-Features Extraction

Overview

spafe: Simplified Python Audio-Features Extraction

Build Status Documentation Status License Python Coverage Status codecov PyPI version anaconda Downloads Codacy Badge codebeat badge

spafe aims to simplify features extractions from mono audio files. The library can extract of the following features: BFCC, LFCC, LPC, LPCC, MFCC, IMFCC, MSRCC, NGCC, PNCC, PSRCC, PLP, RPLP, Frequency-stats etc. It also provides various filterbank modules (Mel, Bark and Gammatone filterbanks) and other spectral statistics.

Installation

Dependencies

spafe requires:

  • Python (>= 3.5)
  • NumPy (>= 1.17.2)
  • SciPy (>= 1.3.1)

User installation

If you already have a working installation of numpy and scipy, you can simply install spafe using pip:

pip install -U spafe

or conda (not available at the moment):

conda install spafe

How to use

Various examples on how to use spafe filter banks or feature extraction techniques are available under examples.

Contributing

Contributions are welcome and encouraged. To learn more about how to contribute to spafe please refer to the Contributing guidelines

Comments
  • Comparing Spafe with librosa and surfboard

    Comparing Spafe with librosa and surfboard

    This is both a comment for the paper and for the repo's README: the first python lib that came to my mind when I saw the review request was librosa. Could you - in the paper's statement of need - elaborate on why this lib is relevant in comparison to what librosa already provides? This would neatly fit with the other challengers (namely, Bob, SpeechPy and python_speech_features). The same argument could be made with the less well-known surfboard.

    As a side note and quasi-request, it'd be nice to have such a comparison outlined in the README. If I were someone that came across this repo, i'd like to know how this is not "yet another audio feature extraction lib", and how this one might fit my needs (especially in comparison to other libs). If I were of bad faith, i'd say i'd like to see a bit of marketing :smiling_imp:

    opened by hadware 8
  • Run examples has TypeError:

    Run examples has TypeError:

    TypeError: dct(): incompatible function arguments. The following argument types are supported: 1. (a: array, type: int, axes: object = None, inorm: int = 0, out: object = None, nthreads: int = 1) -> array

    opened by Amforever 8
  • segmentation fault

    segmentation fault

    segmentation fault occured when my program attempted to access the frames which returned by the function stride_trick the signal length is 1852416 in "stride_trick" a.size returns 3704832

    question 
    opened by weixiu00 6
  • Type hinting and general code review

    Type hinting and general code review

    Reference Issue

    This is part of the code review for JOSS: https://github.com/openjournals/joss-reviews/issues/4739

    This PR is based on the edits from #44 . That other PR should probably be merged before this one.

    What does this implement/fix? Explain your changes.

    This PR has has three aims:

    • I'll add type hints to the function signatures (I hope you don't mind, but I really do love type hints, @hbredin might testify on this)
    • Adding type hints sort of forces me to comb through the code and get a better understanding it of it
    • If I see fishy things I might :
      • either add a # TODO or # WARNING comment for you to solve. You can probably solve them by directly pushing in this PR if you wish
      • correct them myself if they're extremely obvious. In this case you might want to check that I haven't done anything bad.
    opened by hadware 4
  • Fixes to setup, dependencies and CI

    Fixes to setup, dependencies and CI

    Reference Issue

    This is a PR relating to https://github.com/openjournals/joss-reviews/issues/4739#issuecomment-1260768703

    First of all, since this is our first contact, I have to say that this lib is very well made :smiley: , thanks a lot for your work! The code is very clean, the API is very clear, the tests are very exhaustive, and the documentation seems to be very complete.

    The changes in this PR are somewhat nickpicky, but I think they really help making the lib more "standard".

    What does this implement/fix? Explain your changes.

    This fixes and "standardizes" a couple of things:

    • I move most of the constants from the spafe/version.py to the setup.py , as this was not a standard thing to do. If this choice was very opinionated (i.e., you had a very good reason to do so), you can obviously revert that.
    • I put the test and documentation dependencies in tests and docs , in the extras_require field. This is somewhat more standard, and allows the user to run pip install spafe[docs] or pip install spafe[tests] which I think is a bit cleaner. Note that running pip install spafe[anything] installs the "main" dependencies by default.
    • I left the "main" dependencies in the requirements.txt, as i think this to be pretty practical.
    • Having the ability to plot things is very good, but requiring the install of matplotlib by default is, I think, a bit bloated. I made this dependency optional, and added its install through pip install spafe[plotting]. You should probably say something about that in the install instructions.
    • I relaxed the required versions for scipy/numpy ( >= instead of == , this is very useful if spafe has to share its env with some other libraries)
    • I fixed the github actions in several ways:
      • I used a pip install instead of conda install, this makes the tests setup faster and much simpler
      • The old config didn't use the python-version matrix
      • I removed the tests for python 3.5 and 3.6 (they wouldn't be able to run anyway, the required numpy/scipy versions were not available for theses versions of python).
      • I added an action for the documentation. This couldn't run with the others actions, as you don't want a PR branch to activate a doc build.
    opened by hadware 4
  • The discription of

    The discription of " gammatone_fbanks.gammatone_filter_banks" of document is out of the version

    By written in pycharm of the piece of the code in the document, I found that the "return" of the method is not a array of fbanks but a array of "a array of fbanks" and another array that I dont know its mean, I guess it is an array of center frequencies by print it out. Please fix up the document.

    opened by WindDevil 3
  • IndexError: index 3806427 is out of bounds for axis 0 with size 39168

    IndexError: index 3806427 is out of bounds for axis 0 with size 39168

      File "/usr/local/lib/python3.9/site-packages/spafe/features/spfeats.py", line 279, in extract_feats
        feats["mode_frequency"] = frequencies[amplitudes.argmax()]
    IndexError: index 3806427 is out of bounds for axis 0 with size 39168
    
      File "/usr/local/lib/python3.9/site-packages/spafe/features/spfeats.py", line 270, in extract_feats
        feats["peak_frequency"] = frequencies[np.argmax(amplitudes)]
    IndexError: index 3806427 is out of bounds for axis 0 with size 39168
    

    We are getting in the wrong way the argmax() of amplitudes when amplitudes dimensions is greater than 1.

    Moreover, mode_frequency and peak_frequency have the same value, because amplitudes.argmax() and np.argmax(amplitudes) are the same, but this is a different issue https://github.com/SuperKogito/spafe/issues/34

    opened by Helias 3
  • Value error: negative dimensions are not allowed when using spafe library

    Value error: negative dimensions are not allowed when using spafe library

    I am working in audio files and I use this code to extract lfcc features:

    audio_path = '03-01-02-02-01-01-01_norm.wav'

    fs, sig = scipy.io.wavfile.read(audio_path)

    lfcc = lfcc(sig, 13)

    but I have this value error:

    negative dimensions are not allowed
    

    I think that it is because my sig array has negative values, can you give me a way to fix it? Thank you for yor help

    question 
    opened by barrydjenaba 3
  • 'value error: shapes not aligned' while using pncc

    'value error: shapes not aligned' while using pncc

    pnccs = pncc(sig,fs,13) Traceback (most recent call last): File "", line 1, in File "D:\old data\Python\Python35\lib\site-packages\spafe\features\pncc.py", line 205, in pncc b=gammatone_filter.T) File "<array_function internals>", line 6, in dot ValueError: shapes (400,46) and (257,26) not aligned: 46 (dim 1) != 257 (dim 0)

    bug spafe.features 
    opened by mohammadalihumayun 3
  • MFE not found

    MFE not found

    i try this https://spafe.readthedocs.io/en/latest/features/mfcc.html, but got this "ImportError: cannot import name 'mfe' from 'spafe.features.mfcc'"

    bug documentation question 
    opened by ibnudaqiqil 3
  • fix: non-int issue and remove useless variables

    fix: non-int issue and remove useless variables

    Reference Issue

    closes https://github.com/SuperKogito/spafe/issues/14

    What does this implement/fix? Explain your changes.

    • Cast to int frame_length and frame_step as suggested from the issue.
    • Remove unused variables

    Any other comments?

    Thanks https://github.com/aacarneiro/spafe/commit/95a8c785a7982db697a2ee5ff9f57845f5f56f5f @aacarneiro

    opened by Helias 2
Releases(v0.2.0)
Owner
Ayoub Malek
MSc. in EE & IT from TUM, ML engineer, programming enthusiast and coffee addict.
Ayoub Malek
Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications

A Python library for audio feature extraction, classification, segmentation and applications This doc contains general info. Click here for the comple

Theodoros Giannakopoulos 5.1k Jan 2, 2023
Python Audio Analysis Library: Feature Extraction, Classification, Segmentation and Applications

A Python library for audio feature extraction, classification, segmentation and applications This doc contains general info. Click here for the comple

Theodoros Giannakopoulos 3.8k Feb 17, 2021
LibXtract is a simple, portable, lightweight library of audio feature extraction functions.

LibXtract LibXtract is a simple, portable, lightweight library of audio feature extraction functions. The purpose of the library is to provide a relat

Jamie Bullock 215 Nov 16, 2022
cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

audioread Decode audio files using whichever backend is available. The library currently supports: Gstreamer via PyGObject. Core Audio on Mac OS X via

beetbox 419 Dec 26, 2022
cross-library (GStreamer + Core Audio + MAD + FFmpeg) audio decoding for Python

audioread Decode audio files using whichever backend is available. The library currently supports: Gstreamer via PyGObject. Core Audio on Mac OS X via

beetbox 359 Feb 15, 2021
convert-to-opus-cli is a Python CLI program for converting audio files to opus audio format.

convert-to-opus-cli convert-to-opus-cli is a Python CLI program for converting audio files to opus audio format. Installation Must have installed ffmp

null 4 Dec 21, 2022
Audio spatialization over WebRTC and JACK Audio Connection Kit

Audio spatialization over WebRTC Spatify provides a framework for building multichannel installations using WebRTC.

Bruno Gola 34 Jun 29, 2022
Audio augmentations library for PyTorch for audio in the time-domain

Audio augmentations library for PyTorch for audio in the time-domain, with support for stochastic data augmentations as used often in self-supervised / contrastive learning.

Janne 166 Jan 8, 2023
praudio provides audio preprocessing framework for Deep Learning audio applications

praudio provides objects and a script for performing complex preprocessing operations on entire audio datasets with one command.

Valerio Velardo 105 Dec 26, 2022
L-SpEx: Localized Target Speaker Extraction

L-SpEx: Localized Target Speaker Extraction The data configuration and simulation of L-SpEx. The code scripts will be released in the future. Data Gen

Meng Ge 20 Jan 2, 2023
Audio fingerprinting and recognition in Python

dejavu Audio fingerprinting and recognition algorithm implemented in Python, see the explanation here: How it works Dejavu can memorize audio by liste

Will Drevo 6k Jan 6, 2023
Python library for audio and music analysis

librosa A python package for music and audio analysis. Documentation See https://librosa.org/doc/ for a complete reference manual and introductory tut

librosa 5.6k Jan 6, 2023
Scalable audio processing framework written in Python with a RESTful API

TimeSide : scalable audio processing framework and server written in Python TimeSide is a python framework enabling low and high level audio analysis,

Parisson 340 Jan 4, 2023
Python module for handling audio metadata

Mutagen is a Python module to handle audio metadata. It supports ASF, FLAC, MP4, Monkey's Audio, MP3, Musepack, Ogg Opus, Ogg FLAC, Ogg Speex, Ogg The

Quod Libet 1.1k Dec 31, 2022
Python I/O for STEM audio files

stempeg = stems + ffmpeg Python package to read and write STEM audio files. Technically, stems are audio containers that combine multiple audio stream

Fabian-Robert Stöter 72 Dec 23, 2022
Python library for handling audio datasets.

AUDIOMATE Audiomate is a library for easy access to audio datasets. It provides the datastructures for accessing/loading different datasets in a gener

Matthias 121 Nov 27, 2022
A Python library for audio data augmentation. Inspired by albumentations. Useful for machine learning.

Audiomentations A Python library for audio data augmentation. Inspired by albumentations. Useful for deep learning. Runs on CPU. Supports mono audio a

Iver Jordal 1.2k Jan 7, 2023
C++ library for audio and music analysis, description and synthesis, including Python bindings

Essentia Essentia is an open-source C++ library for audio analysis and audio-based music information retrieval released under the Affero GPL license.

Music Technology Group - Universitat Pompeu Fabra 2.3k Jan 3, 2023
Python audio and music signal processing library

madmom Madmom is an audio signal processing library written in Python with a strong focus on music information retrieval (MIR) tasks. The library is i

Institute of Computational Perception 1k Dec 26, 2022