How can I Compare 2 Audio Files Programmatically?

2019-01-21 04:42发布

I want to compare 2 audio files programmatically. For example: I have a sound file in my iPhone app, and then I record another one. I want to check if the existing sound matches the recorded sound or not ( - similar to voice recognition).

How can I accomplish this?

7条回答
淡お忘
2楼-- · 2019-01-21 05:25

That's called Audio Fingerprinting. There exist some open source projects from which you can get some ideas. Take a look here: Audio Fingerprint - MusicBrainz.

查看更多
仙女界的扛把子
3楼-- · 2019-01-21 05:25

Have a server doing audio fingerprinting computation that is not suitable for mobile device anyway. And then your mobile app uploads your files to the server and gets the analysis result for display. So I don't think programming language implementing it matters much. Following are a few AF implementations.

Java: http://www.redcode.nl/blog/2010/06/creating-shazam-in-java/

VC++: http://code.google.com/p/musicip-libofa/

c#: http://www.codeproject.com/KB/WPF/duplicates.aspx

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-21 05:30

I think as well you may try to select a few second sample from both audio track, mnormalise them in amplitude and reduce noise with a band pass filter and after try to use a correlator.

for instance you may take a 5 second sample of one of the thwo and made it slide over the second one computing a cross corelation for any time you shift. (be carefull that if you take a too small pachet you may have high correlation when not expeced and you will soffer the side effect due to the croping of the signal and the crosscorrelation). After yo can collect an array with al the results of the cross correlation and get the index of the maximun.

You should then set experimentally up threshould o decide when yo assume the pachet to b the same. this will change depending on the quality of the audio track you are comparing.

I implemented a correator to receive and distinguish preamble in wireless communication. My script is actually done in matlab. if you are interested i can try to find the common part and send it to you.

It would be a too long code to be pasted hene in the forum. if you want just let me know and i will send it to ya asap.

cheers

查看更多
ら.Afraid
5楼-- · 2019-01-21 05:34
  • Apply bandpass filter to reduce noise
  • Normalize for amplitude
  • Calculate the cross-correlation

It can be fairly Mhz intensive.

The DSP details are in the well known text:

  • Digital Signal Processing by Alan V. Oppenheim and Ronald W. Schafer
查看更多
爷、活的狠高调
6楼-- · 2019-01-21 05:38

I got interested and i found another solution in Java over sourge forge. yo can retrieve the code from SVN.

http://sourceforge.net/projects/comparisong/

give it a look and let me know if it worked for you.

cheers

查看更多
Melony?
7楼-- · 2019-01-21 05:39

Sounds like Shazam might help.

There are a few articles on the web talking about this, including this one that I read a while ago.

Using the Shazam technique for analysis would provide a great starting point for side-by-side comparison.

查看更多
登录 后发表回答