添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

so trying this:

y, sr = librosa.core.load('d:\audio\ChannelRobot\Slice\sliceProducts\RedFloor\RZA_128_Drum_Loop_01.wav')

and getting this traceback:

Traceback (most recent call last):
File "C:/Users/Lindon/OneDrive/Python/SliceFileWrangler/SliceFileWrangler_V01.py", line 94, in
y, sr = librosa.core.load('d:\audio\ChannelRobot\Slice\sliceProducts\RedFloor\RZA_128_Drum_Loop_01.wav')
File "C:\WinPython-64bit-2.7.12.1Zero\python-2.7.12.amd64\lib\site-packages\librosa\core\audio.py", line 123, in load
for frame in input_file:
File "C:\WinPython-64bit-2.7.12.1Zero\python-2.7.12.amd64\lib\site-packages\audioread\rawread.py", line 112, in read_data
data = audioop.lin2lin(data, old_width, TARGET_WIDTH)
audioop.error: Size should be 1, 2 or 4

Librosa.utils.find_files() works fine so I'm a bit stuck about what I'm doing wrong... I've tried this with several audio files all the same result.

Hmm, something is definately not working, I tried this:

xxfilename = librosa.util.example_audio_file()
y, sr = librosa.core.load(xxfilename)

and got this back:
Traceback (most recent call last):
File "C:/Users/Lindon/OneDrive/Python/SliceFileWrangler/SliceFileWrangler_V01.py", line 95, in
y, sr = librosa.core.load(xxfilename)
File "C:\WinPython-64bit-2.7.12.1Zero\python-2.7.12.amd64\lib\site-packages\librosa\core\audio.py", line 109, in load
with audioread.audio_open(os.path.realpath(path)) as input_file:
File "C:\WinPython-64bit-2.7.12.1Zero\python-2.7.12.amd64\lib\site-packages\audioread__init__.py", line 114, in audio_open
raise NoBackendError()
audioread.NoBackendError

no backend error?

For the first error, audioop.lin2lin of python 2 does not support 24bit(3byte) format. Python 3 can handle this.

And the second error says that you don't have any proper decoder for the example file(.ogg in my case). Just try other .mp3 or .wav files. Also, you can ask questions about audioread here .

wontfix Issues that we don't want to deal with: out of scope, intended behavior, deprecations, etc. labels Jul 20, 2016

For the first error, audioop.lin2lin of python 2 does not support 24bit(3byte) format. Python 3 can handle this.

This seems like an error to report upstream in audioread , no?

@bmcfee It's basically an audioop issue, which is fixed in python 3, I'm not sure why they don't apply it to python 2.
I guess they-audioread-already know about this isssue but you know, such reporting will be always appreciated.

I get the same error reading a wav file from a Jupyter Notebook:

wav_file = librosa.load('audio.wav')

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-9-486ba4877d37> in <module>()
----> 1 wav_file = librosa.load(audio.wav)
//anaconda/lib/python2.7/site-packages/librosa/core/audio.pyc in load(path, sr, mono, offset, duration, dtype)
    121         n = 0
--> 123         for frame in input_file:
    124             frame = util.buf_to_float(frame, dtype=dtype)
    125             n_prev = n
//anaconda/lib/python2.7/site-packages/audioread/rawread.pyc in read_data(self, block_samples)
    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

For mp3 or ogg files it works fine, so what I am doing is using pydub to read the wav file, export it as mp3 or ogg and read it again with librosa:

wav_file_pydub = AudioSegment.from_file('audio.wav')
with wav_file_pydub.export('audio.ogg', format='ogg', codec='libvorbis', bitrate='192k') as wav_file:
    wav_file.close()
ogg_file_librosa = librosa.load('audio.ogg')

The problem is I am probably messing up the signal during the conversion. It would be great to have librosa wav reading functionality working for Python 2 as well.

It would be great to have librosa wav reading functionality working for Python 2 as well.

I agree, but this problem is upstream of librosa, as mentioned previously in this thread. I think it's best to report the error to the audioread maintainers.

@kirk86 please file a new issue, rather than add to previously closed/resolved issues. Thanks!

P.S.: Also, you are free to not use librosa.

@kirk86, two things:

  • Your post is a great example of how not to get help or report bugs in an open source project. Maybe give this post a read and then come back when you're ready to behave appropriately.
  • It seems as though you haven't read through this thread and understood why this issue was closed. (TLDR: I think your anger is misdirected.) If you disagree with that assessment, that's fine, but please be concrete and courteous in explaining why you think this thread should be re-opened.
  • Hi everyone, i had struggling the this error for long time but I've figured out what was the problem. Essentially you have to make sure that the ffmpeg library is available to python by publishing its location in the environment variables. To be sure its fine, open a new shell / cmd line window and type ffmpeg -version to see its details. If the result is seen as the installed version you can now run python to execute librosa calls.
    Hope it helps.