patrio2
patrio2

Reputation: 219

Comparing two different audio files doesn't work

I want to compare two audio file for example mp3 and wav. I use musicg to compare by fingerprints.

Wave record1 = new Wave(music1.toString());
Wave record2 = new Wave(music2.toString());
FingerprintSimilarity Similarity=record1.getFingerprintSimilarity(record2);
System.out.println(Similarity.getSimilarity());

musicg work only on wav so I convert mp3 to wav using JAVE

    File temp = new File("temp.wav");
    AudioAttributes audio = new AudioAttributes();
    audio.setCodec("pcm_s16le");
    audio.setBitRate(new Integer(128000));
    audio.setChannels(new Integer(2));
    audio.setSamplingRate(new Integer(44100));
    EncodingAttributes attrs = new EncodingAttributes();
    attrs.setFormat("wav");
    attrs.setAudioAttributes(audio);
    Encoder encoder = new Encoder();
    encoder.encode(source, temp, attrs);

And now the problem, when I try compare two wav that I don't convert fingerprints work perfect but when I compare two different audio that I have to convert it's always return that both audio are same. Wave create record1 the same spectrogram as record2 when I give to it two different audio.

Upvotes: 6

Views: 766

Answers (1)

slipperyseal
slipperyseal

Reputation: 2778

File temp = new File("temp.wav");

both Waves are backed by the same file. :)

Upvotes: 2

Related Questions