Wav file convert to byte array in java

前端 未结 4 2077
慢半拍i
慢半拍i 2020-12-01 11:49

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 byt

4条回答
  •  悲哀的现实
    2020-12-01 12:28

    Write this file into ByteArrayOutputStream

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(WAV_FILE));
    
    int read;
    byte[] buff = new byte[1024];
    while ((read = in.read(buff)) > 0)
    {
        out.write(buff, 0, read);
    }
    out.flush();
    byte[] audioBytes = out.toByteArray();
    

提交回复
热议问题