splitsafe
Check your audio train / validation / test folders for leakage before you train.
Core Architectural Finding:
SplitSafe brings established spectral landmark fingerprinting techniques into an integrated, partition-aware audio ML dataset auditing workflow—guaranteeing zero evaluation contamination and speaker boundary integrity before model training.
If the same recording (or a re-encoded, resampled, louder, trimmed or clipped copy of it) sits on both sides of a split, your test score is measured on something the model has already seen, so it looks better than it really is. splitsafe finds those files, and also shows which speakers appear in more than one split.
It is small, runs on your own computer, never changes your files, and uses classic signal processing (spectral-peak fingerprints). There is no neural network and no model download.
Install
pip install --pre splitsafe
(--pre is needed because this is an alpha release. Python 3.10 or newer.)
Use
splitsafe check train/ val/ test/
Each folder is one split (subfolders are included). Example output from a small synthetic demo (two recordings were copied into the test folder, one resampled, one cut into a short clip):
splitsafe verdict: FAIL
Splits: test (4 files), train (5 files)
LEAKAGE: 2 file pair(s) appear on both sides of a split (4 files involved).
[same audio (re-encoded / trimmed / re-leveled)] test/leaked_copy.wav <-> train/spk9_a.wav (aligned matches: 925, overlap: 100%)
[same audio (re-encoded / trimmed / re-leveled)] test/leaked_clip.flac <-> train/spk1_a.wav (aligned matches: 93, overlap: 29%)
SPEAKERS in more than one split: 1
spk0: train=1, test=1
The exit code is 0 for PASS or WARN, 1 for FAIL, 2 for a usage error, so it can run in CI.
Speakers
Speaker overlap is only checked if you tell it who is who:
splitsafe check train val test --speaker-regex '^[^/]+/(spk[0-9]+)_' # one capture group = the speaker id
splitsafe check --manifest data.csv # columns: file,split[,speaker]
Shared speakers give a WARN (for speech recognition this is often acceptable). Add --strict-speakers to make it a FAIL, which is usually right for speaker ID or voice cloning.
Options
| Option | What it does |
|---|---|
--names a,b,c |
Split names (default: the folder names) |
--manifest file.csv |
Use a CSV with file,split[,speaker] instead of folders. --base DIR sets what the file paths are relative to |
--out DIR |
Write splitsafe_report.json, cross_split_duplicates.csv, splitsafe_report.txt, and splitsafe_report.html |
--html PATH |
Write interactive HTML listening report with side-by-side audio players |
--json |
Print JSON instead of text |
Use from Python
from pathlib import Path
from splitsafe import check_splits
from splitsafe.scan import items_from_folders
from splitsafe.report import to_text
res = check_splits(items_from_folders([Path("train"), Path("test")]))
print(res.verdict()) # "PASS", "WARN" or "FAIL"
for m in res.matches: # every leaked pair
print(m.a, m.b, m.kind, m.votes)
print(to_text(res))
What it checks
| Check | Finds |
|---|---|
| Exact copies | Byte-identical files in different splits |
| Same audio | The same recording after re-encoding (wav/flac), resampling, gain change, noise, trimming, or a short clip cut from a longer file |
| Shared speakers | Speakers (from your labels) that appear in more than one split |
Duplicates inside one split are not reported, because they are not leakage.
Limitations (please read)
- Alpha. Tested only on synthetic audio so far (21 automatic tests, run on Linux, macOS and Windows in CI). It has not yet been measured on real speech or music datasets. The default threshold was chosen from synthetic data. On real data, tune
--min-votesand check a few reported pairs by listening. - A PASS is not a guarantee. Only the checks above are done. It cannot tell that two different recordings contain the same sentence, and it cannot find the same speaker without labels.
- Heavy changes can hide a copy: strong time-stretching, pitch-shifting, or very low-bitrate re-encoding may drop below the threshold.
- Files that cannot be fingerprinted (shorter than 1 second, silent, or unreadable) are listed under "NOT fully checked". Only exact byte copies are checked for them.
- Speaker embeddings (finding the same voice without labels) are planned, not included.
- The fingerprint idea (spectral peak pairs with time-offset voting) is a well-known technique. Chromaprint-based tools such as audiomatch compare whole files. splitsafe's contribution is packaging it for train/test checks, including partial and clipped copies, with a clear verdict.
How it works
Each file is turned into hashes of pairs of loud spectral peaks (frequency 1, frequency 2, time gap). Two files that share audio share many hashes at one consistent time offset. Random coincidences between different recordings do not line up in time, so counting aligned matches separates real copies from chance.
Check it on real data
scripts/real_data_check.py runs splitsafe on two real, officially separate folders (for example LibriSpeech dev-clean and test-clean), reports any false alarms, plants changed copies of real files on the other side, and counts how many are found. See docs/REAL_DATA_CHECK.md.
Development
pip install -e ".[dev]"
python -m pytest -q
Contributing
Bug reports with a small example are the most useful. If splitsafe flags two files that are not the same audio, or misses a copy, please open an issue with the numbers from the report.
License
MIT. See LICENSE.
Metadata
Release files for splitsafe 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| splitsafe-0.1.0.tar.gz | 21.9 kB | Without provenance | Details for splitsafe-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| splitsafe-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for splitsafe-0.1.0-py3-none-any.whl |
Total release size: 39.6 kB
Release files / splitsafe-0.1.0.tar.gz
| Download URL | splitsafe-0.1.0.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87c55b38530ab9b2f0522c8a15413667e81f521da7689c35c3206813ff2697a0
|
|
BLAKE2b-256 checksum How to use checksums |
5947f3c7ed8521ca3b524f19641d8d185acc6163451b057aee109715ca04461e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / splitsafe-0.1.0-py3-none-any.whl
| Download URL | splitsafe-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a12e2c1304adec6cf373c402c427e02479a316ac6d81c8f536d0f1ce017e829a
|
|
BLAKE2b-256 checksum How to use checksums |
b9ce03b7801bfd6810c29a28d01589c0e0e720cd74db206ce2b9504012a96ed9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Security for splitsafe 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.