Borrar filtros
Borrar filtros

Problem reading wav files: error in audioread (line 137)

16 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Keerthana Ramesh
Keerthana Ramesh el 17 de Ag. de 2022
Movida: Walter Roberson el 17 de Ag. de 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
  1 comentario
Diego Bianchera
Diego Bianchera el 23 de Ag. de 2022
I'm sorry if this seems trivial, but I have issues understanding the use of bytes.' in strfind and I have troubles making this work. I'm reading documentation at the moment and making an attempt. If I find a solution to my problem I will post the final code I used.
I really appreciate the input you gave me. I think I'm heading in the right direction. Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Timing and presenting 2D and 3D stimuli en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by