Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have 2 audio files that are from almost the same source. But at some points there shifted a bit. Also the codecs does not match.

I would like to make a program that takes a sample 2 - 4 seconds. And looks for it in the other file. (Most of the time it's not shifted more than 30 seconds). Than take the time and store it, Go ahead for a few seconds take a sample and find it again. This way i want to create a file where i can see on what points the file is shifted.

For people who are more interested in what i want. I have a audio/video file speech and subtitles. But i have same speech from different sources with differs a bit in time. And i like to make a program that can correct the subtitle time for me.

Enough about the problem

I looked on the Internet for ways to compare audio files. Based on what i read comparing 2 audio files isn't that easy as i had hoped.

Some talk about algorithms

http://www.perlmonks.org/?node_id=169641

Some audio-library's portaudio.com aubio.org sourceforge.net/projects/ccaudio/ ambiera.com/irrklang/

The biggest problem i have is that i can't find something i can generate from the audio that i can use to compare with.

I hope someone here can point me in the right direction.

share|improve this question

4 Answers

You should use the programming language you can most easily deal with that has a good library for doing that. Many things in modern file formats aren't as easy as you might hope, and the solution to that is libraries that other people, who do understand the issues, have written.

share|improve this answer

If you have strong background in mathematics and statistics you may implement your algorithms based on pattern recognition/neural networks.

Some algorithms:

share|improve this answer

You can do that with any audio library. Here is one you can use with most popular languages:

share|improve this answer

I am using this javascript function for audio comparison

function compireAudio(){ 
var audio1 = "http://soundjax.com/reddo/86502%5Ealarm.mp3"; 
var audio2 = "http://soundjax.com/reddo/44368%5EALARME.mp3";
var i,j,d;
var matching = 0;
var t = 0;var i,j,d;
var matching = 0;
var t = 0;
var audio1Arr = Array();
var audio1Len = audio1.length;
for (i = 1; i<=audio1Len; i++)
{
    //reverse so its like a stack
    d = audio1.charCodeAt(audio1Len-i);
    for (j = 0; j < 8; j++) 
    {
        audio1Arr.push(d%2);
        d = Math.floor(d/2);
    }
}
var audio2Len = audio2.length;
for (i = 1; i<=audio2Len; i++)
{
    //reverse so its like a stack
    d = audio2.charCodeAt(audio2Len-i);
    for (j = 0; j < 8; j++) 
    {
        if(d%2 == audio1Arr[t])
        {
            matching++;
        }
        d = Math.floor(d/2);
        t++;
    }
}
var avarage = Number(matching)/((Number(t)+Number(audio1Arr.length))/Number(2))*Number(100);
alert('The Matching with the two audio is '+avarage+' %.');

}

share|improve this answer
Whoah, looks like you're comparing the URLs here, rather than the audio data. – JBRWilkinson May 24 '12 at 17:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.