-->

How can I Compare 2 Audio Files Programmatically?

2019-01-21 05:28发布

问题:

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?

回答1:

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.



回答2:

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



回答3:

I know the question has been asked a long time ago, but a clear answer could help someone else.

  1. The libraries from Echoprint ( website: echoprint.me/start ) will help you solve the following problems :

    • De-duplicate a big collection
    • Identify (Track, Artist ...) a song on a hard drive or on a server
    • Run an Echoprint server with your data
    • Identify a song on an iOS device

    PS: For more music-oriented features, you can check the list of APIs here.

  2. If you want to implement Fingerprinting by yourself, you should read the docs listed as references here, and probably have a look at musicip-libofa on Google Code

Hope this will help ;)



回答4:

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.



回答5:

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



回答6:

  • 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


回答7:

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