1

I have a very long audio file (10 hours). I also have a shorter audio file (10 seconds). The short audio file is a small piece of the long audio file. I.e the long audio file in some place contains the short audio file. But I don't know where.

How can I search in the long audio file for the short audio file? In other words how I can match these 2 files and find where in the long file the short file occurs?

I'm using OSX 10.12.16 but can accept solutions for Windows, OSX, or Linux.

1 Answer 1

2

Audio files are essentialy arrays (or vectors) of numeric values. If the audio files are uncompressed, the short audio file should exactly match a sequence of values within the long audio file. That means you could use tools like Matlab, Octave, Python (with modules) etc. to read in the audio as an array-like data type and then use provided functions to search for the shorter sequence in the longer one.

If the audio files are compressed, it's not certain that their numeric values will exactly match. In that case, you could either preprocess them by quantizing them to a lower bit depth (e.g. from 16 bit to 8 bit) and hope that afterwards they'll match. Or you could compute the cross-correlation between the two signals and see where they are correlated the strongest—that should be the point where they match. The cross-correlation can also be computed with the tools linked above.

4
  • Great answer. Just wanted to mention Scilab as an alternative to Matlab because it's free. Commented Jan 26, 2018 at 9:41
  • @Steffen Rummel Thank you. About modules, can you give me any suggestion? I'll probably go with Python since I am more familiar with it. The audio files are compressed (sorry I didn't mention that originally), but I can get uncompressed versions. I will try both methods you outlined as I'm interested to experiment/learn with this.
    – penname
    Commented Jan 26, 2018 at 16:08
  • @Schizomorph Thank you. I'll check it out.
    – penname
    Commented Jan 26, 2018 at 16:11
  • @penname Since I personally use Matlab for everything DSP related, these are just educated guesses: numpy, scipy and scikit-dsp seem to have everything you need (scipy will probably suffice, see this question and answer). Commented Jan 26, 2018 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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