Skip to main content

Find the offset of an audio file within another audio file

Project description

audio-offset-finder

A simple tool and library for finding the offset of an audio file within another file.

Uses cross-correlation of standardised Mel-Frequency Cepstral Coefficients, so should be relatively robust to noise (encoding, compression, etc). The accuracy is typically to within about 0.01s.

The tool outputs the calculated offset in seconds, and a "standard score" representing the prominence of the chosen correlation peak. This can be used as an estimate of the accuracy of the calculated offset - one with a score greater than ten is likely to be correct (at least for audio without similar repeated sections) within the accuracy of the tool; an offset with a score less than five is unlikely to be correct, and a manual check should be carried out.

The tool uses ffmpeg for transcoding, so should work on all file formats supported by ffmpeg.

Installation

To install from this source directory once downloaded:

$ pip install .

Or, to install the latest package from PyPi.org:

$ pip install audio-offset-finder

Usage

$ audio-offset-finder --help
$ audio-offset-finder --find-offset-of file1.wav --within file2.wav
Offset: 12.26 (seconds)
Standard score: 21.102

To provide additional information about the accuracy of the result in addition to the standard score, the --plot option shows a plot of the cross-correlation curve. A single well-defined peak such as is shown in the image below is a good indication that the offset is correct.

A line graph showing a sharp prominent peak emerging from low-level noise

Testing

$ pytest

Licensing terms and authorship

See 'COPYING' and 'AUTHORS' files.

The audio file used in the tests was downloaded from Wikimedia Commons, and was originally extracted from the 9 July 2008 episode of the BBC Today programme.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audio-offset-finder-0.4.0.tar.gz (10.2 kB view hashes)

Uploaded Source

Built Distribution

audio_offset_finder-0.4.0-py3-none-any.whl (11.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page