Problem reading wav files: error in audioread (line 137)
11 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I'm having an issue reading .wav files using audioread function and I get the following message every time:
Error using audioread>readaudio
File could not be read due to an unexpected error. Reason: Error in WAV file. No 'data' chunk marker.
Error in audioread (line 137)
[y, Fs] = readaudio (filename, range, datatype);
Even audioinfo fails to read the files, with the following error:
Error using audioinfo>extractinfo
File could not be read due to an unexpected error. Reason: Error in WAV file. No 'data' chunk marker.
Error in audioinfo (line 91)
info = extractinfo(filename);
I am sure the syntax and the rest of the code is fine as it works in Matlab Online, but it doesn't work in the desktop application.
I suspect it may be the particular sample rate they have, which is 46875 and which I (sadly) cannot change.
Is there any compatibility issue with audioread regarding sample rates, that you know of? Is there anything I can do except keep on using the online version of Matlab to make it work?
Thank you.
0 个评论
采纳的回答
Keerthana Ramesh
2022-8-17
移动:Walter Roberson
2022-8-17
Hi,
This error of “File could not be read due to an unexpected error. Reason: Error in WAV file. No 'data' chunk marker” could be caused by the .wav file not abiding by the standardized format. The function 'audioread' relies on Windows Media Foundation WMF and can only read the standard format.
The workaround requires editing the bytes of the wav file. The following code helps in deleting the extra bytes and converting the .wav file to the standard format:
>> loc = strfind( bytes.', uint8('data') ); % Find where the 'data' keyword is.
>> bytes( 37:loc-1 ) = []; % Delete the extra bytes.
>> f = fopen( 'tmp.wav', 'w' );
>> fwrite( f, bytes, '*uint8' ); % Write the new byte sequence.
>> fclose( f );
>> [y, Fs] = audioread( 'tmp.wav' ); % Read the audio file.
WMF expects bytes 37-40 to store the keyword 'data', so the extra bytes between 37 and the first byte of the keyword need to be deleted.
I hope the above workaround solves the issue. If it does not, may I please know the MATLAB version you are using?
Thanks,
Keerthana
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!