Reading wav file in Java

后端 未结 5 1833
清酒与你
清酒与你 2020-11-27 20:44

I want to read wav files in Java and I am going to classify them with K-means.

How can I read wav files in Java and assign them into an array or something like that(

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 20:51

    Not sure if this will help someone. Java JDK already provides AudioSystem class.

    I used this as part of my tests to check generated WAV properties,

    AudioFileFormat audioFileFormat = AudioSystem.getAudioFileFormat(new File(response.get()));
    assertEquals(1, audioFileFormat.getFormat().getChannels());
    assertEquals(8000.0, audioFileFormat.getFormat().getSampleRate(), 0.0f);
    assertEquals(8, audioFileFormat.getFormat().getSampleSizeInBits());
    

提交回复
热议问题