Skip to main content

aislice

CI PyPI Python License: MIT

Lock AI-generated music to a fixed BPM grid, then slice it by bar or beat.

AI music (Suno, Udio, …) rarely holds a steady tempo: it drifts across the song, so it never lines up with a DAW grid. aislice tracks every beat, builds a clean tempo map, and time-stretches the song in one variable-ratio pass, so every beat lands exactly on the target grid. Pitch is preserved. Then it cuts sample-accurate slices.

Line chart: an AI-generated piano track drifts from 206 to 214 BPM over 3 minutes; after aislice it stays flat at 206.0 BPM.

Status: v0.1.0, an early release. Feedback and issues are welcome.

Install

Requirements: Python 3.10+, ffmpeg, and the Rubber Band command-line tool.

# macOS
brew install ffmpeg rubberband
pip install aislice

# latest from GitHub
pip install git+https://github.com/VNL-Works/ai-music-slicer

# or, for development
git clone https://github.com/VNL-Works/ai-music-slicer && cd ai-music-slicer
pip install -e .

Use

aislice song.mp3 other.wav          # asks for BPM and slice unit
aislice ./folder --bpm 206 --slice bar

Output (one folder per input):

aislice_output/song_206bpm/
├── song_206bpm.wav     # whole song locked to the grid (24-bit, source sample rate)
├── slices/             # song_bar_001.wav, song_bar_002.wav, ...
├── report.json         # detected tempo map, corrections, verification
└── tempo.png           # before/after plot

Slice units: 1/16, 1/8, beat, bar, 2bar, 4bar, 8bar, any Nbar / Nbeat (e.g. 16bar, 3beat), or none.

Fixing a wrong bar start

If slice 1 doesn't start on the "1", move the bar start without re-processing:

aislice reslice "aislice_output/song_206bpm" --shift 2      # bar 1 = 2 beats later
aislice reslice "aislice_output/song_206bpm" --slice 4bar,8bar

aislice prints a warning when it isn't sure where bar 1 is.

How it works

  1. Analyze: high-resolution onset envelope (~3 ms frames) and a local tempo curve, then a dynamic-programming beat tracker whose expected period follows the song's drift.
  2. Calibrate: beat markers are aligned to the actual note attacks, so slices start just before each transient.
  3. Clean the tempo map: fix missed and extra beats, ignore weak beats in fade-ins and fade-outs, and smooth out tracking jitter while keeping real drift. Then find the bar downbeat.
  4. Warp: one Rubber Band R3 pass with a time map (source beat → target grid line), with the first downbeat placed on a bar line.
  5. Slice at exact grid positions, then verify by re-tracking the output.

Development

pip install -e ".[dev]"
pytest

The tests build synthetic songs with a known, drifting tempo and chords that change on each bar. That gives exact ground truth for beat timing, downbeat detection, slicing and the full end-to-end run. The end-to-end test needs rubberband and ffmpeg installed and is skipped otherwise. CI runs everything on Python 3.10–3.13. See AGENTS.md for architecture and invariants, and CHANGELOG.md for releases.

License

MIT © VNL Works

aislice calls the Rubber Band command-line tool as a separate program. Rubber Band itself is GPL-2.0+ (commercial licenses are available from its authors) and is installed separately.

Metadata

Release files for aislice 0.1.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 aislice 0.1.0
File Size Uploaded
aislice-0.1.0.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aislice 0.1.0
File Interpreter ABI Platform
aislice-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / aislice-0.1.0.tar.gz

Download URL aislice-0.1.0.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7fc62ab1acad7ac490ba5b22bf82bb6eba1ad1c551848ebebc629dfa384f6901
BLAKE2b-256 checksum
How to use checksums
15043e804a393255d46b2a96f78a6aadc7dd18300938249a5ada83c484790b3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / aislice-0.1.0-py3-none-any.whl

Download URL aislice-0.1.0-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
263647a7b45f5820ddafe75464efed1147e0bf73297625e62c965458653013ab
BLAKE2b-256 checksum
How to use checksums
2002ed3871792c37364b3c442f1c8fc7b8b491eebea9c345477746ca20215679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.0 This release

2 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