python-soundfile
python-soundfile copied to clipboard
soundfile read ogg files error
Here is my code.
filename='kfc.ogg' data, samplerate = sf.read(filename) Then throw Error File "/PycharmProjects/.env/lib/python3.7/site-packages/soundfile.py", line 1184, in _open "Error opening {0!r}: ".format(self.name)) File "/PycharmProjects/.env/lib/python3.7/site-packages/soundfile.py", line 1357, in _error_check raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace')) RuntimeError: Error opening 'kfc.ogg': File contains data in an unimplemented format.
Could you upload that file, so we ca have a look?
How did you install soundfile?
pip install soundfile sudo apt-get install libsndfile kfc.ogg.zip
Do you know if your version of libsndfile does in fact support OGG?
@kyowill
Your .ogg file is encoded with opus, while last version of libsndfile as well as pysoundfile can process only vorbis encoded files.
I see your OGG file contains OPUS audio. As far as I know, libsndfile does not support OPUS.
I think now it support oppus, please check https://libsndfile.github.io/libsndfile/formats.html
I installed soundfile==0.11.0, and in release it writes "Updates libsndfile to v1.1.0". When I import soundfile and print libsndfile_version, I get '1.0.28', which does not support ogg/opus Is there any way to upgrade the libsndfile of soundfilev0.11.0?
Hi, you need to install it from source
I was trying to install it on aws lambda.
#all files are stored in var/task
RUN yum update -y && yum install gcc-c++ make -y
#with yum the cmake version is <3 and we need >3
# https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0.tar.gz
#OpenSSL(libssl-devel) for cmake
COPY cmake-3.24.0 ${LAMBDA_TASK_ROOT}/cmake3
RUN cd cmake3 && ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF && make && make install && cd ..
# # RUN wget https://github.com/libsndfile/libsndfile/archive/refs/tags/1.1.0.tar.gz
# # RUN tar xf 1.1.0.tar.gz
COPY libsndfile-1.1.0 ${LAMBDA_TASK_ROOT}/libsndfile
RUN cd libsndfile && cmake -G"Unix Makefiles" && make && make install && cd ..
I think i am able to install the latest version. The above commands are docker commands. I just posted them for the hint
That's not enough. You also need to install all the dependencies for Opus before you compile libsndfile. Have a look at https://github.com/bastibe/libsndfile-binaries/blob/master/mac_build.sh to get an idea of what is needed. On Linux, you can obviously install most dependencies from your package manager instead of compiling them manually.