Wav file convert to byte array in java

arrays, audio, java, javasound, wave

Solution

Basically as described by the snippet in the first answer, but instead of the `BufferedInputStream` use `AudioSystem.getAudioInputStream(File)` to get the `InputStream`.

Using the audio stream as obtained from `AudioSystem` will ensure that the headers are stripped, and the input file decode to a byte[] that represents the actual sound frames/samples - which can then be used for FFT etc.

Problem

My project is 'Speech Recognition of Azeri speech'. I have to write a program that converts `wav` files to byte array. How to convert audio file to byte[]?

Original source