python-soundfile icon indicating copy to clipboard operation
python-soundfile copied to clipboard

UserWarning: PySoundFile failed. Trying audioread instead.

Open aviasd opened this issue 5 years ago • 2 comments

I use an AWS sagemaker ml.t2.medium machine. This is the distributaion:

Linux ip-172-16-23-13 4.14.171-105.231.amzn1.x86_64 #1 SMP Thu Feb 27 23:49:15 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I downloaded libsndfile with:

sudo wget http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28.tar.gz
tar -xzf libsndfile-1.0.28.tar.gz

And installed with:

cd libsndfile-1.0.28
./configure --prefix=/usr --disable-static --docdir=/usr/share/doc/libsndfile-1.0.28 && make
sudo make install

Then, I downloaded pysndfile with:

pip install pysoundfile

Now, everything is working great when trying to read a .wav file with librosa.
But when I am trying to read a .flac file, it is writing:

/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/librosa/core/audio.py:161: UserWarning: PySoundFile failed. Trying audioread instead.
  warnings.warn('PySoundFile failed. Trying audioread instead.')

It is working with audioread, but I think the pysndfile should work either.
libsndfile does support .flac format.
What can be the cause of this?
Maybe my installation is not enough and I need to install the codec for .flac in libsndfile somehow?

Thank you,

aviasd avatar Apr 15 '20 19:04 aviasd

You didn't enable support for flac in your libsndfile. Please refer to the documentation of libsndfile of how to compile in flac support.

bastibe avatar Apr 16 '20 06:04 bastibe

@aviasd FLAC support is compiled in automatically, but libFLAC must be available.

See https://github.com/bastibe/libsndfile-binaries#dylib-for-mac-os-x-64-bit for an example how to compile all those libraries. This example compiles everything into one single file. If you want to compile and use the libraries on the same (virtual) machine and don't care about having multiple interdependent libraries, you can probably drop all the arguments to ./configure when building libFLAC (I think so, but I didn't actually try).

mgeier avatar Apr 16 '20 08:04 mgeier