Comparing two different audio files doesn't work

夙愿已清 提交于 2019-12-23 09:04:15

问题


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.


回答1:


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

both Waves are backed by the same file. :)



来源:https://stackoverflow.com/questions/31603508/comparing-two-different-audio-files-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!