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.
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
Built Distribution
Hashes for audio-offset-finder-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e488d43f4c7c3e653771ada495b42169e110d8111a0e7f4392e20e6ca4e20078 |
|
MD5 | 44fe09056eee9de60b985e636e7e6dc2 |
|
BLAKE2b-256 | db63c95b59e0cafdaf48ae924f5ea15966e384e8c29f36f5d301aaf86e1e5aed |
Hashes for audio_offset_finder-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ceccefa4d0762ee73b6e6bb6e0d89459109cb9173dff1494bbca4468a0b3f74 |
|
MD5 | c21778826e562ac91b287bcd324fe444 |
|
BLAKE2b-256 | 8557b5087a64ffe4770a06b89234907640643442d2e1695fd87cadb8ce8f79b5 |