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
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
samplerate : 16 Khz
channels : mono
It have an error code like this
Exception 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.getAudioInputStrea m(Unknown Source)
at Recorder.run(Recorder.java:73)
I try to use code in java like this
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.