-
Notifications
You must be signed in to change notification settings - Fork 4
Using sounddiff in CI
sounddiff can run in your CI/CD pipeline to catch audio regressions automatically. The --ci and --threshold flags let you define acceptable limits and fail the build if they're exceeded.
sounddiff --ci --threshold loudness=0.5,peak=0.3 reference.wav output.wavIf either threshold is exceeded, sounddiff exits with code 1 and prints which thresholds failed.
| Code | Meaning |
|---|---|
| 0 | All thresholds pass |
| 1 | One or more thresholds exceeded |
| 2 | Error (bad input, missing file, invalid threshold) |
| Key | What it checks | Unit | Example |
|---|---|---|---|
loudness |
Absolute LUFS delta | dB |
loudness=0.5 (fail if loudness changes by more than 0.5 dB) |
peak |
Absolute true peak delta | dBTP |
peak=0.3 (fail if peak changes by more than 0.3 dBTP) |
lra |
Absolute loudness range delta | LU |
lra=1.0 (fail if dynamic range changes by more than 1.0 LU) |
duration |
Absolute duration delta | seconds |
duration=0.01 (fail if duration changes by more than 10ms) |
correlation |
Minimum overall correlation | 0-1 |
correlation=0.99 (fail if waveforms diverge) |
spectral |
Max absolute spectral band delta | dB |
spectral=3.0 (fail if any frequency band changes by more than 3 dB) |
You can combine any number of thresholds:
sounddiff --ci --threshold loudness=0.5,peak=0.3,correlation=0.99,spectral=3.0 ref.wav test.wavThresholds depend on what your pipeline does. Here are starting points for common scenarios:
Should produce bit-identical output:
--threshold loudness=0.01,peak=0.01,correlation=0.999Expect some change, but not too much:
--threshold loudness=0.5,peak=0.5,spectral=6.0,correlation=0.95Loudness will change (that's the point), but spectral balance and structure should be preserved:
--threshold spectral=1.0,correlation=0.98,duration=0.01Tight control over everything:
--threshold loudness=0.3,peak=0.2,lra=0.5,spectral=2.0,correlation=0.97name: Audio Quality Check
on: [push]
jobs:
audio-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install sounddiff
run: pip install sounddiff
- name: Run audio regression test
run: |
sounddiff --ci --threshold loudness=0.5,peak=0.3 \
tests/fixtures/reference.wav \
tests/fixtures/output.wavThe --ci flag works with any output format. The threshold check happens after the report is generated, so you can get both a human-readable report and a CI exit code:
# Generate HTML report AND check thresholds
sounddiff --ci --threshold loudness=0.5 \
--format html -o report.html \
reference.wav output.wav
# Generate JSON for further processing AND check thresholds
sounddiff --ci --threshold loudness=0.5 \
--format json \
reference.wav output.wav > results.jsonThe exit code reflects the threshold check regardless of output format.