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.

It would be nice if librosa.load(path, sr) would support a format-kwarg.

See original GitHub issue

Is your feature request related to a problem? Please describe. I am currently dealing with python inmemory file objects (io.BytesIO etc.). They don’t have a file extension which is why librosa.load() cannot recognise them properly as paths and I get: RuntimeError: Error opening <_io.BytesIO object at 0x7f1ed40ff090>: Format not recognised.

Describe the solution you’d like librosa.load() uses a SoundFile object internally which in fact already supports format as a kwarg. Please propagate that kwarg to the function call so that a user can define the extension of the file manually (=> librosa.load(path, sr, format))

Describe alternatives you’ve considered At the moment, I am using pydub.AudioSegments for that. But it is not as clean as that one librosa call would be.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bmcfeecommented, Dec 13, 2021

@Lavair thanks for checking back, and sorry that it’s taken so long to get to this one. But I’m glad you were able to work around it.

To put it simply, the (in progress) PR and proposed resolution would have resulted in something like the following for you:

sfo = sf.SoundFile(path, format=format, [... other kwargs])
y, sr = librosa.load(sfo)

Not quite as slick as promoting all soundfile parameters up to the librosa API, but much easier to maintain and not too much more difficult to use. It does sound to me like your original issue was a bit subtler than just specifying format, but I think the proposed solution should otherwise sufficiently resolve things.

0reactions
c0mr4tcommented, Dec 13, 2021

Hmm, sorry that I didn’t respond earlier. You must know that I finished the project where I used librosa somewhere around July and don’t have access to it anymore 😅

As you can image, I forgot the exact situation I had here and I cannot reasonably comment on it, sorry 😬 …but apparently, you already made a pr anyway. 👍 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

librosa.load — librosa 0.10.0.dev0 documentation
Path ) are supported as path. If the codec is supported by soundfile , then path can also be an open file descriptor...
Read more >
Problem getting librosa.load to work · Issue #390 - GitHub
so trying this: y, sr = librosa.core.load('d:\audio\ChannelRobot\Slice\ ... It would be great to have librosa wav reading functionality ...
Read more >
librosa.load() takes too long to load(sample) mp3 files
This warning will always occur when loading mp3 because libsndfile does not (yet/currently) support the mp3 format. Librosa tries to use ...
Read more >
Librosa: A Python Audio Libary. by - Medium
Librosa's load function will read in the path to an audio file, and return a ... If you want to change the sample...
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