I have code that extracs the MFCC values from a wav file:
public class MFCCTest {
public static void main(String[] args) throws Exception {
int sampleRate = 41000;
int bufferSize = 512;
int bufferOverlap = 128;
final List<float[]>mfccList = new ArrayList<>(200);
InputStream inStream = new FileInputStream("event10.wav");
AudioDispatcher dispatcher = new AudioDispatcher(new UniversalAudioInputStream(inStream, new TarsosDSPAudioFormat(sampleRate, bufferSize, 1, true, true)), bufferSize, bufferOverlap);
final MFCC mfcc = new MFCC(bufferSize, sampleRate, 20, 50, 300, 3000);
dispatcher.addAudioProcessor(mfcc);
dispatcher.addAudioProcessor(new AudioProcessor() {
@Override
public void processingFinished() {
}
@Override
public boolean process(AudioEvent audioEvent) {
mfccList.add( mfcc.getMFCC());
return true;
}
});
dispatcher.run();
for (int loop = 0 ; loop < mfccList.size(); loop++) {
System.out.println("outer ");
for (int loop2 = 0 ; loop2 < mfccList.get(loop).length; loop2++) {
System.out.println(loop2 + " " + mfccList.get(loop)[loop2]);
}
}
}
}
Now I need to perdorm Dynamic Time Warping on the MFCC values to compare the wav files.
However the code for this requires that I compare two files in ascii format:
public static void main(String[] args) {
new DTW("pattern.ascii", "pattern.ascii")
}
I am having trouble figuring out how to convert the MFCList of float value arrays :
final List<float[]>mfccList = new ArrayList<>(200);
into an ascii file format.
Any advice or recomendations about how to do this would be greatly appreciated.