librosa / librosa

Python library for audio and music analysis

Home Page:https://librosa.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module 'scipy.signal' has no attribute 'hann'

babycommando opened this issue · comments

Hello there Librosa team, beautiful work being done.

I am working on a music analyzer for the following:

import librosa
import numpy as np

# Load audio file
audio_file = 'grimesbody.mp3'
y, sr = librosa.load(audio_file)

# Extract audio features
tempo, _ = librosa.beat.beat_track(y=y, sr=sr)
spectral_centroid = np.mean(librosa.feature.spectral_centroid(y=y, sr=sr))
zero_crossing_rate = np.mean(librosa.feature.zero_crossing_rate(y))
chroma_stft = np.mean(librosa.feature.chroma_stft(y=y, sr=sr))
rms = np.mean(librosa.feature.rms(y=y))
mfcc = np.mean(librosa.feature.mfcc(y=y, sr=sr, n_mfcc=13))
spectral_contrast = np.mean(librosa.feature.spectral_contrast(y=y, sr=sr))
tonnetz = np.mean(librosa.feature.tonnetz(y=y, sr=sr))

# Format data into JSON style
data = {
    "audio_features": [
        {
            "tempo": tempo,
            "spectral_centroid": spectral_centroid,
            "zero_crossing_rate": zero_crossing_rate,
            "chroma_stft": chroma_stft,
            "rms": rms,
            "mfcc": mfcc.tolist(),  # Convert numpy array to list
            "spectral_contrast": spectral_contrast.tolist(),  # Convert numpy array to list
            "tonnetz": tonnetz.tolist()  # Convert numpy array to list
        }
    ]
}

print(data)

However I'm being thrown this error no matter what I change on it:
AttributeError: module 'scipy.signal' has no attribute 'hann'.

Software versions*

INSTALLED VERSIONS
------------------
python: 3.12.2 (main, Feb 21 2024, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)]

librosa: 0.10.1

audioread: 3.0.1
numpy: 1.26.4
scipy: 1.13.0
sklearn: 1.4.2
joblib: 1.4.0
decorator: 5.1.1
numba: 0.59.1
soundfile: 0.12.1
pooch: v1.8.1
soxr: 0.3.7
typing_extensions: installed, no version number available
lazy_loader: 0.4
msgpack: 1.0.8

numpydoc: None
sphinx: None
sphinx_rtd_theme: None
matplotlib: None
sphinx_multiversion: None
sphinx_gallery: None
mir_eval: None
ipython: None
sphinxcontrib.rsvgconverter: None
pytest: None
pytest_mpl: None
pytest_cov: None
samplerate: None
resampy: None
presets: None
packaging: 23.1

This is probably related to #1830

Yes, this is a dupe of #1830 and is already fixed.

Yes, this is a dupe of #1830 and is already fixed.

already fixed but not deployed to the main branch or is it supposed to be working already? If not when should we be seeing this out? literally can't use the lib atm.

Fixed, merged into main, and scheduled for the upcoming 0.10.2 release. Release is only held up by a PR on documentation #1801 at this point, but a main branch install should be usable.