Changelog¶
The file in git is CHANGELOG.md.
0.3.0 - 2026-09-30¶
The first release meant for PyPI: every attack now follows its paper, the backends and metrics were audited, and the project has CI, coverage, a documentation site and a real-model benchmark.
Breaking¶
- CW
c: now weights the CTC (classifier) term in||delta||_2^2 + c * CTC, matching Carlini & Wagner 2018 (audio). Previouslycweighted the L2 term. - CW defaults:
epsilon ≈ 2000/32768,c=1.0,learning_rate ≈ 10/32768,num_iter=5000,decrease_factor_eps=0.8,optimizer="adam",early_stop=False,search_eps=True. - Imperceptible defaults: stage iterations/learning rates and
alpha=0.05follow Qin et al. 2019 (int16 hyperparameters scaled to[-1, 1]). Stage 1 uses SGD sign steps; stage 2 uses Adam. - Imperceptible
c: deprecated and ignored (DeprecationWarning if passed). Stage 2 isCTC + alpha * l_thetawith nocfactor.
Added¶
- Optional
label=on FGSM, BIM, PGD, CW, and Imperceptible for untargeted true-label attacks. normin{inf, 2, 1}for FGSM, BIM, and PGD; PGDrestarts; BIM step count from the paper's rule.- Imperceptible
mode("imperceptible","robust","imperceptible_robust"),roomsandrobust_delta, withRoomSimulator(newasr_attacks.rooms) for over-the-air robustness.RoomSimulator.from_rirstakes your own impulse responses; generating rooms needs the newroomsextra (pyroomacoustics). - Audio CW Sec. III-C (
loss="margin"), Sec. III-F (target=""), anddb_bound/db_distortion. ASRAttacks(..., verbose=), andverboseon every stage of every attack (see Fixed).- Documentation site (MkDocs Material) with a guide per attack, a paper-to-code map, the API reference and an ethics page.
- A real-model benchmark:
scripts/benchmark_wav2vec2.pyattacks torchaudio's wav2vec2 on LibriSpeech and writes the benchmark page. Install its dependencies with the newbenchmarkextra.
Fixed¶
verbose=Falsesilenced nothing. The progress bars ignored it; PGD's result was swallowed in a real-model run. Every loop in BIM, PGD, CW, the margin refinement and every Imperceptible stage (including the robust modes) now obeysverbose.- Targets that cannot fit the model's output (more tokens, plus a blank between repeats, than logit frames) returned NaN audio without a warning.
ctc_lossnow raises aValueErrorthat says how many frames are needed and how many exist, and useszero_infinity=Trueso genuinely infinite terms cannot poison the gradient. - Hugging Face input normalization.
HuggingFaceCTCBackendskipped the processor'sdo_normalizestep, so attacks optimized a different signal than the model sees in deployment.logits()now applies zero-mean/unit-variance normalization in autograd when the feature extractor asks for it. - NaN gradient in the psychoacoustic loss whenever the perturbation was zero or constant over a frame (for example when stage 2 started from unchanged stage-1 audio): the STFT magnitude used
sqrt, whose slope is infinite at 0. It now uses the complexabs, with a zero subgradient there. librosaandnumbacrashed the real imperceptible path (Numba needs NumPy 1.26 or less) and forced tests to mock the masking code. The masking threshold now uses a NumPy STFT that reproduceslibrosa.stft(center=False), andlibrosa(withnumba) is no longer a dependency.- Imperceptible + robust decoded all M rooms on every step in its IR stages (800 decodes for 80 steps). It now decodes only at the scheduled check steps, as the paper's schedule needs.
Changed¶
attacks/cw.py(892 lines mixing three concerns) is split intocw.py,imperceptible.pyand_optim.py. Behaviour is unchanged andfrom asr_attacks.attacks.cw import imperceptiblekeeps working.- The package is type-checked with mypy, formatted and linted with Ruff, and the test suite measures branch coverage (about 90 %). Tests now execute code paths that used to be skipped silently, notably the CW margin refinement, and pin the schedules of the Imperceptible attack.
- CI runs pre-commit, Ruff and mypy, the tests on Python 3.10–3.12 (Linux) and 3.12 (macOS, Windows) with coverage uploaded to Codecov, and a wheel install smoke test. Releases go to TestPyPI on demand and to PyPI from a GitHub Release, using trusted publishing.
0.2.0 - 2026-09-11¶
First packaged release of asr-attacks.
- Add Apache-2.0 license, NOTICE (IBM ART attribution), pyproject.toml, tests, CI, and this documentation site.
- Split the single 1,500-line class into backends, attacks, and metrics.
- Encode targets from the model vocabulary instead of a hardcoded wav2vec2 map.
- Project BIM/PGD onto the L-inf ball around the original waveform.
- Return NumPy arrays via
.detach().cpu().numpy()so CUDA tensors do not crash. - Replace homemade positional WER with jiwer (Levenshtein).
wer_computeno longer returns1 - WERfor targeted evaluation. - Use
tqdm.autoso the library imports outside Jupyter. - Document that the CW-named attack is CTC + L2, not paper-faithful Carlini–Wagner.
0.1.0 - 2023-11-07¶
Initial research code (unpublished).