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.

`import librosa` slow to run at 48 seconds

See original GitHub issue

Describe the bug

import librosa takes way too long, at 48 seconds.

To Reproduce

import librosa

# Start a stopwatch to time it.
# Stop the stopwatch when the Python prompt becomes responsive/available again.
# In my case, it takes 48 seconds.

Expected behavior Would expect it to go fast.

Software versions

Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import platform; print(platform.platform())
Linux-5.10.104-linuxkit-x86_64-with-glibc2.29

>>> import sys; print("Python", sys.version)
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0]

>>> import numpy; print("NumPy", numpy.__version__)
NumPy 1.22.4

>>> import scipy; print("SciPy", scipy.__version__)
SciPy 1.8.1

>>> import librosa; print("librosa", librosa.__version__)
librosa 0.9.2

>>> librosa.show_versions()
INSTALLED VERSIONS
------------------
python: 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0]

librosa: 0.9.2

audioread: 2.1.9
numpy: 1.22.4
scipy: 1.8.1
sklearn: 1.1.1
joblib: 1.1.0
decorator: 5.1.1
soundfile: 0.10.3
resampy: 0.3.1
numba: 0.55.2
pooch: v1.6.0
packaging: 21.3

numpydoc: None
sphinx: None
sphinx_rtd_theme: None
sphinx_multiversion: None
sphinx_gallery: None
mir_eval: None
ipython: None
sphinxcontrib-svg2pdfconverter: None
pytest: None
pytest-mpl: None
pytest-cov: None
matplotlib: None
samplerate: None
soxr: None
contextlib2: None
presets: None

System:

  • I’m running things inside of a Docker container running heroku/heroku:20 (based off Ubuntu 20).
    • If I run import librosa from the host computer running macOS the speed is normal.
    • The Mac is a 2021 MacBook Pro M1.

Additional context

What I’ve tried:

  • Restarting my Docker container;
  • Uninstalling / Reinstalling librosa

There’s no error message in the prompt. Where could I look for additional information? (Say logs, or how to run libsndfile or other from the command-line?)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bmcfeecommented, Aug 5, 2022

This will be resolved with the 0.4 release of resampy next week, and requires no further action from the librosa side.

1reaction
fabswtcommented, Jul 21, 2022

Found the culprit: it’s indeed resampy.

  • The 48-second import time is with resampy 0.3.1.
  • Downgrading to 0.3.0 or 0.2.2 gave me import times of 5-7 seconds. Not great, but better.
Read more comments on GitHub >

github_iconTop Results From Across the Web

librosa becomes slower the longer it runs · Issue #681 - GitHub
The time to execute load and mfcc always increases. (Maybe only one of them; I didn't tested.) Versions. >>> import platform; print(platform.
Read more >
Reading a wav file with scipy and librosa in python
I do find strange though that the librosa. load() function offers a dtype parameter but works anyways only with float values. Googling in...
Read more >
librosa.load — librosa 0.10.0.dev0 documentation
Load an audio file as a floating point time series. Audio will be automatically resampled to the given rate (default sr=22050 ). To...
Read more >
Parallelized Spectrogram as numpy - Kaggle
If audio is less than 5 seconds first, then it is assumed to have a bird call (so no_call cannot be there) and...
Read more >
Comparing Signals
First, from within Notebook, you can execute the following two lines within a cell (you'll only need to run this once): import sys...
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