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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file audio-offset-finder-0.4.0.tar.gz.

File metadata

  • Download URL: audio-offset-finder-0.4.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.8

File hashes

Hashes for audio-offset-finder-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e488d43f4c7c3e653771ada495b42169e110d8111a0e7f4392e20e6ca4e20078
MD5 44fe09056eee9de60b985e636e7e6dc2
BLAKE2b-256 db63c95b59e0cafdaf48ae924f5ea15966e384e8c29f36f5d301aaf86e1e5aed

See more details on using hashes here.

File details

Details for the file audio_offset_finder-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for audio_offset_finder-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ceccefa4d0762ee73b6e6bb6e0d89459109cb9173dff1494bbca4468a0b3f74
MD5 c21778826e562ac91b287bcd324fe444
BLAKE2b-256 8557b5087a64ffe4770a06b89234907640643442d2e1695fd87cadb8ce8f79b5

See more details on using hashes here.

Supported by

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