I need some help with java to convert sound‏

Joined
Dec 27, 2008
Messages
1
Reaction score
0
First off all I need to sorry to disturb you about this but I really have a big problem. and I am really need your help.

I have a problem because my Speech recognition tool kit need to use sound in 16Khz mono .wav format to work. but my microphone is
44.100 KHz and stereo format. and it's don't have 16khz mono format in microphone setting.
I try to use java to convert this wave file. but when i convert sound

//My Input wave File
AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,44100.0F, 16, 2, 4, 44100.0F, false);

encoding - PCM_Signed
sampleRate - 44.1 KHz
sampleSizeInBits - 16
channels - Stereo
frameSize - 4
frameRate - 44100
bigEndian - false

to
// Wave file format that i want
samplerate : 16 Khz
channels : mono


It have an error code like this


xception in thread "Thread-5" java.lang.IllegalArgumentException: Unsupported conversion: PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian from PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian

at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)

at Recorder.run(Recorder.java:73)

I try to use code in java like this
//My Source code

File inputfile = new File("test.wav");

AudioFormat xx = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,16000.0F, 16, 1, 2, 16000.0F, false);
m2_audioInputStream = AudioSystem.getAudioInputStream(xx, m_audioInputStream);

but It can't work

I try to find a lot of solutions in Internet but it seem can't solve my problem . So It will be very kindness if you tell me how can I convert this wave file.
by using java.

Than you a lot for your help.

Nuttapong
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top