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.

librosa.load (audioread) breaks on this audio file, not sure why?

See original GitHub issue

Calling librosa.load('101729.wav', sr=None) (download file here) gives the following error:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-172-5d71d5777356> in <module>()
----> 1 audio, sr = librosa.load('101729.wav', sr=None)

/Users/justin/dev/miniconda3/envs/py27/lib/python2.7/site-packages/librosa/core/audio.pyc in load(path, sr, mono, offset, duration, dtype)
    121         n = 0
    122 
--> 123         for frame in input_file:
    124             frame = util.buf_to_float(frame, dtype=dtype)
    125             n_prev = n

/Users/justin/dev/miniconda3/envs/py27/lib/python2.7/site-packages/audioread/rawread.pyc in read_data(self, block_samples)
    110 
    111             # Make sure we have the desired bitdepth and endianness.
--> 112             data = audioop.lin2lin(data, old_width, TARGET_WIDTH)
    113             if self._needs_byteswap and self._file.getcomptype() != 'sowt':
    114                 # Big-endian data. Swap endianness.

error: Size should be 1, 2 or 4

Must be something about the file’s format that causes the problem, though I’m not sure what. Here’s the file info (as returned by pysox):

{'bitrate': 24,
 'channels': 2,
 'duration': 84.580021,
 'encoding': 'Signed Integer PCM',
 'num_samples': 4059841,
 'sample_rate': 48000.0,
 'silent': False}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
justinsalamoncommented, Sep 10, 2018

@pratistha you mentioned pyaudio, but my solution was to use pysoundfile (pip install pysoundfile). Then loading the audio is just:

import soundfile as sf
data, samplerate = sf.read('existing_file.wav')

Hope this helps!

3reactions
dpwecommented, Jul 12, 2017

To quote brmcfee, please refer to this thread https://groups.google.com/d/topic/librosa/Z1-HXBsHLi0/discussion.

DAn.

On Wed, Jul 12, 2017 at 3:53 AM, Khalidhussain1134 <notifications@github.com

wrote:

Hi Bmcfee, I got error while reading audio file using librosa.load(file.wav)

File “D:/DECASE2017/urbansoudclassification/urban.py”, line 37, in extract_features sound_clip, s = librosa.load(fn)

File “C:\Users\CL_1\Anaconda3\lib\site-packages\librosa\core\audio.py”, line 107, in load with audioread.audio_open(os.path.realpath(path)) as input_file:

File “C:\Users\CL_1\Anaconda3\lib\site-packages\audioread_init_.py”, line 116, in audio_open raise NoBackendError()

NoBackendError

What type of this error will be? Thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/librosa/librosa/issues/477#issuecomment-314685060, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhs0f3Yc3mLz19vdyNyM0GVMhkwrkOuks5sNHtmgaJpZM4LLDtd .

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Source code for librosa.core.audio
This is primarily useful for processing large files that won't fit entirely in memory at once. Instead of loading the entire audio signal...
Read more >
Source code for librosa.core.audio
SoundFile, audioread object, or file-like object path to the input file. ... Instead of loading the entire audio signal into memory (as in...
Read more >
Troubleshooting — librosa 0.10.0.dev0 documentation
If you're loading an audio file, and see the following message: UserWarning: PySoundFile failed. Trying audioread instead. Do not worry. This is a...
Read more >
Advanced I/O Use Cases
Blockwise Reading¶. For large audio signals it could be beneficial to not load the whole audio file into memory. Librosa 0.7 introduced a...
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