我有一些代码可以从wav文件中提取MFCC值:
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]);
}
}
}
}
现在我需要对MFCC值进行动态时间规整以比较wav文件。
但是,此代码要求我比较两个ascii格式的文件:
public static void main(String[] args) {
new DTW("pattern.ascii", "pattern.ascii")
}
我在弄清楚如何转换浮点值数组的MFCList时遇到麻烦:
final List<float[]>mfccList = new ArrayList<>(200);
转换为ascii文件格式。
任何有关此操作的建议或建议,将不胜感激。