Problem reading wav files: error in audioread (line 137)
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Diego Bianchera
le 14 Août 2022
Commenté : Diego Bianchera
le 23 Août 2022
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 commentaires
Réponse acceptée
Keerthana Ramesh
le 17 Août 2022
Déplacé(e) : Walter Roberson
le 17 Août 2022
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Audio and Video Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!