transformers
4444567d - Add the numpy and torch audio backends

Commit
85 days ago
Add the numpy and torch audio backends Implements the two concrete numeric backends behind `BaseAudioProcessor`: - `NumpyAudioBackend` — pure numpy/scipy framing, STFT, mel projection and log scaling, bit-exact with librosa and kaldi. - `TorchAudioBackend` — the same frontends on torch, bit-exact with torchaudio, and able to run on GPU. Both read the `SpectrogramConfig` added in the previous commit and implement the same small set of array-API primitives, so every model processor picks a backend and supplies a config rather than reimplementing STFT/mel/log framing. The two are held to each other by the equivalence tests that land with the first model. `TorchAudioBackend` is decorated with `@requires(backends=("torch",))` so model processors inherit the guard instead of each repeating it, matching the lazy torch-import hygiene applied to the legacy feature extractors, and torch itself is imported behind `is_torch_available()`. No model is migrated here and `SequenceFeatureExtractor` is untouched, so every existing feature extractor keeps working unchanged.
Author
Committer
Parents
Loading