I am having trouble in converting the audio format of a WAV file.
I am recording sound from my microphone and the sound is recorded in the following format:
PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame
I want to convert the above format to,
ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame
I am using the following code,
InputStream is = request.getInputStream();
AudioInputStream ais = AudioSystem.getAudioInputStream(is);
AudioFormat oldFormat = ais.getFormat();
AudioFormat newFormat = new AudioFormat(AudioFormat.Encoding.ULAW, 8000, 8, 1, 1, 8000, false) ;
AudioInputStream lowResAIS = AudioSystem.getAudioInputStream(newFormat, ais); //Getting the below Exception on this line
And I am getting the following error,
java.lang.IllegalArgumentException: Unsupported conversion: ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, from PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian
Can someone please help me solve this problem!!!
Thanks a ton!!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…