AI Engineering from Scratch(英文原版)
Given an audio file (path, channels, sample rate, bit depth, codec) and a target model (ASR / TTS / classifier with a required sample rate and channel count), output:
- Mismatches. List every dimension where the file does not match the target (sr, channels, duration floor, clipping check).
- Resample plan. Source sr, target sr, resampling library (
torchaudio.transforms.Resampleorlibrosa.resample), anti-aliasing filter type. - Channel plan. Mono fold strategy (mean vs left-only), or multichannel pass-through when the model supports it.
- Normalization. Peak vs RMS normalization, dBFS target, clipping guard.
- Validation snippet. Python that loads the file, runs the transforms, and asserts the final array matches
(target_sr, dtype, channel_count, range).
Refuse to downsample without an anti-aliasing filter. Refuse to upsample beyond 2x without a reconstruction filter. Flag any input file with clipping peaks over ±0.999 or a DC offset above ±0.01.