New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
BUG: scipy.io.wavfile.read stays in infinite loop, warns on wav files converted from Sphere #6700
Comments
Thanks for reporting the problem and providing the test file. I can confirm that the problem also occurs with the latest version of scipy from github (dfaca96), using Python 3.5.2 with numpy 1.11.1 on a Mac running OS X 10.9.5. |
good to see it has confirmed on other versions and OS as well. hope a solution can be found to fix this bug. |
If the RIFF chunk contains false information about the file size, `scipy.io.wavfile.read()` gets stuck in an infinite loop as it tries to read beyond the EOF. Notice that the `mmap=True` call is still broken if the `data` chunk has wrong size specification as well. See scipy#6700
The problems seems to be that the You can run this small program: from scipy.io.wavfile import _read_riff_chunk
from os.path import getsize
filename = "problem.wav"
with open(filename, 'rb') as f:
riff_size, _ = _read_riff_chunk(f)
print('RIFF size: {}'.format(riff_size))
print('os size: {}'.format(getsize(filename))) It outputs
I implemented a small patch that compares the file size in the RIFF chunk with the file size as reported by the OS (PR #6716). Then I read
This basically means that |
Concerning PR #6716:
EDIT: Corrected the second sentence, added a question about unit tests. |
I've investigated the reason and I found out for some cases the sph2pipe was failing so it created shorter wav files than it supposed to. So the header probably reflects the length of the data in sphere format but since the conversion was failing at some point, there are some files where the header is wrong. |
If the RIFF chunk contains false information about the file size, `scipy.io.wavfile.read()` gets stuck in an infinite loop as it tries to read beyond the EOF. Notice that the `mmap=True` call is still broken if the `data` chunk has wrong size specification as well. See scipy#6700
If the RIFF chunk contains false information about the file size, `scipy.io.wavfile.read()` gets stuck in an infinite loop as it tries to read beyond the EOF. Notice that the `mmap=True` call is still broken if the `data` chunk has wrong size specification as well. See scipy#6700
If the RIFF chunk contains false information about the file size, `scipy.io.wavfile.read()` gets stuck in an infinite loop as it tries to read beyond the EOF. Notice that the `mmap=True` call is still broken if the `data` chunk has wrong size specification as well. See scipy#6700
Changed to raise an exception, as the file is malformed. |
my wave file was malformed too.. with other file didn't happend!! thanks |
Hello, I know this post is closed, but I recently ran into the similar issue, due to a malformed header. However, in our group, this issue was not uncovered earlier as all other tools - MATLAB, Adobe Audition, Windows Media Player are able to successfully read the data chunk, even though the chunkSize field is not entered correctly. Also, python's own standard library wave ( ) reads the data properly. It sizes the data chunk itself, and uses that. Given, how so many approaches are available to read the data successfully, it would be good for scipy.io.wavfile( ) to also continue to get the correct data, and change the current valueError to a warning. Should I open a new ticket for this? |
I converted some Sphere audio files using sph2pipe_v2.5 and some of the resulting wave files can not be read using scipy.io.wavfile.
It shows this warning:
wavfile.py:267: WavFileWarning: Chunk (non-data) not understood, skipping it. WavFileWarning)
and keeps reading in an infinite loop which never ends.
Here is the wav file causing the problem.
problem.wav.tar.gz
Other libraries (such as wavio) are able to read this file without any problem.
Also I could open the wav file and access the content via sonic visualizer with no issue.
My python version:
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
My scipy version:
scipy.__version__ '0.18.0'
My OS:
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=16.04 DISTRIB_CODENAME=xenial DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS" NAME="Ubuntu" VERSION="16.04.1 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.1 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" UBUNTU_CODENAME=xenial
The text was updated successfully, but these errors were encountered: