Import wav file in Tensorflow 2

It seems like your error has to do with TensorFlow expecting the fmt part as the beginning.

The code of TensorFlow for the processing can be found here: https://github.com/tensorflow/tensorflow/blob/c9cd1784bf287543d89593ca1432170cdbf694de/tensorflow/core/lib/wav/wav_io.cc#L225

There's also an open issue, awaiting response from TensorFlow's team which roughly covers the same error you've provided. https://github.com/tensorflow/tensorflow/issues/32382

Other libraries just skip the Junk part, so it works with them.


It seems that your code fails for dual channel audio file. The code works for mono channel wav file. In your case you can try using scipy.

from scipy.io import wavfile as wav
sampling_rate, data =  wav.read('101415-3-0-2.wav')