Skip to main content

fast-align-audio: high-speed NumPy audio alignment

fast-align-audio is designed to swiftly align two similar 1-dimensional NumPy arrays — a common need in various fields including audio signal processing. If you have two arrays where one "lags behind" the other due to factors such as different capture sensors (microphones), propagation delays, or post-processing like reverberation or MP3 compression, fast-align-audio is here to help.

The package employs a "brute force" alignment approach, leveraging a C-based algorithm for maximum speed while providing a user-friendly Python API for easy integration.

While this library was initially developed with audio ndarrays in mind, it could also be used to align other kinds of time-series data that are represented as 1D NumPy arrays.

Installation

PyPI version python 3.9, 3.10, 3.11, 3.12, 3.13 os: Linux, Windows

$ pip install fast-align-audio

Usage

Here is a basic usage example:

import fast_align_audio
import numpy as np

# Create a random NumPy array
reference = np.random.uniform(size=10_000).astype("float32")
delayed = np.pad(reference, (121, 0))[0:10_000]

# Find the best offset for aligning two arrays
offset, mse = fast_align_audio.find_best_alignment_offset(
    reference_signal=reference,
    delayed_signal=delayed,
    max_offset_samples=1000,
    lookahead_samples=5000,
)
print(offset)  # 121

negative_offset, mse2 = fast_align_audio.find_best_alignment_offset(
    reference_signal=reference,
    delayed_signal=reference[121:],
    max_offset_samples=1000,
    lookahead_samples=5000,
)
print(negative_offset)  # -121

# Align two arrays and confirm they're equal post alignment
aligned_audio, gaps = fast_align_audio.align_delayed_signal_with_reference(
    reference.shape[-1], delayed, offset=offset
)
print(np.array_equal(reference[500:600], aligned_audio[500:600]))  # True

In this example, we first create a random numpy array. We then call the find_best_alignment_offset method to find the best offset to align two arrays, and we use the align method to align the arrays. The np.array_equal method checks if two arrays are equal, demonstrating the successful alignment of the two original arrays.

Tips

  • For more reliable alignments, filter out unwanted/unrelated sounds before passing the audio snippets to fast-align-audio. E.g. if you are aligning two speech recordings, you could band-pass filter and/or denoise them first.
  • This library assumes that the delay is fixed throughout the audio snippet. If you need something that aligns audio tracks in a dynamic way (e.g. due to distance between microphones changing over time), look elsewhere.
  • The "mse" method is sensitive to loudness differences. If you use this method, make sure the two input audio snippets have roughly the same loudness
  • This lib only works well for small offsets, like up to 500 ms, and suitable audio file durations, like for example between 3 and 45 seconds. If you have large audio files with large offsets between them, a different algorithm may be required to solve the problem well.

Changelog

[0.6.0] - 2025-06-28

Added

  • Add support for Python 3.13

For the complete changelog, go to CHANGELOG.md

Development

  • Install dev/build/test dependencies as denoted in setup.py
  • python setup.py develop
  • pytest

Acknowledgements

Original C implementation by jonashaag. Now maintained/backed by Nomono.

Release files for fast-align-audio 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-align-audio 0.6.0
File Size Uploaded
fast_align_audio-0.6.0.tar.gz 8.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for fast-align-audio 0.6.0
File
fast_align_audio-0.6.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
fast_align_audio-0.6.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details
fast_align_audio-0.6.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
fast_align_audio-0.6.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details
fast_align_audio-0.6.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
fast_align_audio-0.6.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.5+ x86-64, Linux glibc 2.17+ x86-64 Details
fast_align_audio-0.6.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
fast_align_audio-0.6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.5+ x86-64, Linux glibc 2.17+ x86-64 Details
fast_align_audio-0.6.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
fast_align_audio-0.6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details

Total release size: 185.0 kB

Release files / fast_align_audio-0.6.0.tar.gz

Download URL fast_align_audio-0.6.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ca48021e4b65de132ccaeac5fb13bbef0e0ce4ee285ae5c060c86ac502c1559b
BLAKE2b-256 checksum
How to use checksums
8cf49deebd56258311c7bd6e3f62fbe9575ad6828fd42aadca02dc530a1d114f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp313-cp313-win_amd64.whl

Download URL fast_align_audio-0.6.0-cp313-cp313-win_amd64.whl
Size 14.3 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2a3ac7acb8919cadd0fde45f88218192f990b84819f9db3b1eacfb1709e9ef6a
BLAKE2b-256 checksum
How to use checksums
3d711ce6583c1a26c611f58bf03986a23951b1efcc42c49270bcad7de7402eed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_align_audio-0.6.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 21.1 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
0a948a0a937d1d8645c8dde638bc917c32189cb62636b1fb5b72f428733762ef
BLAKE2b-256 checksum
How to use checksums
1b24002fd337915f49b94bb627a7f3c2549a0f4ed778ba947c471d9a875995e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp312-cp312-win_amd64.whl

Download URL fast_align_audio-0.6.0-cp312-cp312-win_amd64.whl
Size 14.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
799377ba756edbcdf4da8a478ad6102090a83d191e6713ab8b869d1afa2f6633
BLAKE2b-256 checksum
How to use checksums
f00f5347a0e0319edb414ab663721841c919e4719803babe24b8dc89d7d20716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_align_audio-0.6.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 21.2 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
7a54a0bc251b8265f8346272ca5104b141ce96445b28d4b4d6647d2783e2299c
BLAKE2b-256 checksum
How to use checksums
e5f2ff8cc8936523d46ee585c6f489142dbda14c4c35c5eb34ab583dcc6c14a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp311-cp311-win_amd64.whl

Download URL fast_align_audio-0.6.0-cp311-cp311-win_amd64.whl
Size 14.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
89413548e6a1d22b3a21a822aabf9b39f46116ee31adfd7e9b62c22a64c06f22
BLAKE2b-256 checksum
How to use checksums
4d07a1d33cf6e026a53412f42ab54d57c1e2c3242b65f5ea724cff9f263c69b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_align_audio-0.6.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 20.9 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
0b3ca8db8f23b2a4912702c4792fab0d2b4092e848e574ed21deadc2f2b8e8d6
BLAKE2b-256 checksum
How to use checksums
ccca23b4a7753444577d33ec3e3a01fe3ca451586ce80c1946ea8b139d528aaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp310-cp310-win_amd64.whl

Download URL fast_align_audio-0.6.0-cp310-cp310-win_amd64.whl
Size 14.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5801b6de4450a666e8bbb2e7e6d659490810946b13101d369c2a88f96ddaa41d
BLAKE2b-256 checksum
How to use checksums
dc5cc95ca080d7d3bc1742dcebed6df07622a58dc4f94a66a4367e32f9f5a58e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_align_audio-0.6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 20.9 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
29c4ab063801db9676fb1a464aa0316ee732fb40546ee700a8c2591f5c19891c
BLAKE2b-256 checksum
How to use checksums
36cc576a608b6a1d8cb2b4fa75ca5750fb56dc73097e2ea2bc0673a690498c5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp39-cp39-win_amd64.whl

Download URL fast_align_audio-0.6.0-cp39-cp39-win_amd64.whl
Size 14.3 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
f9cf21113e0bdda69459494452e6359301a45c0c9aab68588bce76aeb2de54e6
BLAKE2b-256 checksum
How to use checksums
b99ec01a329b19d721665e28e4a4651fbc995c09a433731eb3ea2886e75933c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / fast_align_audio-0.6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL fast_align_audio-0.6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 20.9 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
deb87404b162248111984aa53916d0d5016987424886d0bcda3b44090c5a09ec
BLAKE2b-256 checksum
How to use checksums
7bc700c40c06a76b4f6e0ed0be102c7fc22c7e44f2523b7f65275d8cf92146f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.6.0 This release

11 release files

0.5.0

9 release files

0.4.0

7 release files

0.2.1

18 release files

0.1.1

16 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page