[Speex-dev] JSpeex - Unsupported conversion
Rich Carlson
jrc at brainhotel.org
Mon Jan 7 23:50:25 PST 2008
I'm having difficulty encoding audio using the JSpeex Speex Encoder. My
program throws an "Unsupported conversion" exception and I can't figure
out why. I've read the related posts and I think I'm doing everything that
was recommended. I'm working on Linux, by the way.
Any help would be greatly appreciated.
Richard
Here is my program output:
$ java -classpath ".:jspeex/src/java" SpeexSave in.wav out.wav
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported
conversion: SPEEX_quality_3, 44100.0 Hz, -1 bit, stereo, audio data from
PCM_SIGNED, 44100.0 Hz, 16 bit, stereo, little-endian, audio data
at
javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:571)
at SpeexSave.main(SpeexSave.java:36)
And here is my program:
import java.io.*;
import javax.sound.sampled.*;
// Speex imports.
import org.xiph.speex.*;
import org.xiph.speex.spi.*;
class SpeexSave {
public static void main(String args[]) {
if (args.length != 2) {
System.out.println("Arguments: IN_WAVE_FILE OUT_WAVE_FILE");
return;
}
File srcFile = new File(args[0]);
File outFile = new File(args[1]);
AudioInputStream audioInputStream = null;
try {
audioInputStream = AudioSystem.getAudioInputStream(srcFile);
}
catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
e.printStackTrace();
return;
}
AudioFormat srcFormat = audioInputStream.getFormat();
AudioFormat targetFormat =
new AudioFormat(SpeexEncoding.SPEEX_Q3,
srcFormat.getSampleRate(),
-1, // sample size in bits
srcFormat.getChannels(),
-1, // frame size
-1, // frame rate
srcFormat.isBigEndian());
AudioInputStream audioInputStream2 =
AudioSystem.getAudioInputStream(targetFormat,
audioInputStream);
}
}
More information about the Speex-dev
mailing list