0

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.

Lcarrins
  • 47
  • 5
  • Just to make sure I understand. You want to convert the values in your `List` of `float[]` arrays to `String`s and write them to a text file. Correct? – Abra Jun 26 '19 at 16:15
  • @Abra Seeing as the DTW code requires the code to be in asquii format I think that I need to do this yes – Lcarrins Jun 26 '19 at 17:36
  • Do you know how to convert a `float` to a `String`? Do you know how to write a `String` to a file (in java)? – Abra Jun 26 '19 at 20:19
  • How about you implement DTW yourself? – Nikolas Rieble Aug 19 '19 at 18:10

0 Answers0