-1

I'm struggling alot with converting mp3 to wav and changing the format so it's 16 bit. I have a program that downloads a mp3 file from google translate's text-to-speech which is mono, 16000Hz, 32 bit. The only thing that needs change is 32 bit -> 16 bit. I have searched alot but I think I'm just a bit noob and I'm always doing something wrong. I'm searching for the right java article but I used the wrong one and couldn't convert it.

Florens
  • 91
  • 12
  • _I have a program_ We can help you more if you show us the essential parts. – Jonas Czech Apr 27 '15 at 20:29
  • Check [this](http://stackoverflow.com/questions/12586949/how-can-i-convert-a-wav-file-in-java) and [this](http://stackoverflow.com/questions/10515174/conversion-of-audio-format). – Jonas Czech Apr 27 '15 at 20:31
  • 1
    I have looked into mp3spi xhich will probably work for me but the platform I'm currently trying to get y working on makes it really hard to add external jars. But the creator told me they are adding support for eclipse claspah creating. – Florens Jun 19 '15 at 18:42

1 Answers1

0

Java doesn't support MP3 without additional librarys. List of supported formats: JMF 2.1.1 - Supported Formats

However, to convert the bitrate between two .wav files, you can use javax.sound.sampled:

import javax.sound.sampled.*;

public void changeBitrate(File source,File output){
  AudioFormat format=new AudioFormat(44100,16,1,true,true);
  AudioInputStream in=AudioSystem.getAudioInputStream(source);
  AudioInputStream convert=AudioSystem.getAudioInputStream(format,in);
  AudioSystem.write(convert,AudioFileFormat.Type.WAVE,output);
}
0xJonas
  • 289
  • 1
  • 7