| Crates.io | spectrs |
| lib.rs | spectrs |
| version | 0.2.1 |
| created_at | 2025-10-15 18:10:32.562582+00 |
| updated_at | 2025-10-25 15:01:46.014148+00 |
| description | Fast spectrogram creation library |
| homepage | https://github.com/giacomopiccinini/spectrs |
| repository | https://github.com/giacomopiccinini/spectrs |
| max_upload_size | |
| id | 1884764 |
| size | 222,898 |
Fast spectrogram creation library.
spectrs is a Rust library for creating spectrograms from audio files. It provides:
Install the binary with full features (CLI + image support):
cargo install spectrs
When using spectrs as a library dependency, you typically want minimal dependencies. Add it with:
# Minimal dependencies (core audio and spectrogram functionality only)
cargo add spectrs --no-default-features
# With image export support
cargo add spectrs --no-default-features --features image
After installing with cargo install spectrs, you can process audio files from the command line.
The CLI will automatically create PNG images with the same name as the input file(s).
# Process a single file with default settings
spectrs audio.wav
# Create a mel spectrogram with 128 mel bands
spectrs audio.wav --n-mels 128
# Customize spectrogram parameters
spectrs audio.wav \
--n-fft 2048 \
--hop-length 512 \
--n-mels 128 \
--spec-type power \
--colormap viridis
# Walk a directory and process all WAV files, placing output files alongside WAV files
spectrs audio_folder/
# Walk a directory and process all WAV files, placing output files in another directory
# with the same nested structure (if any) of the input directory
spectrs audio_folder/ --output-dir processed_audio_folder/
# See all available options
spectrs --help
spectrs supports multiple colormaps for spectrogram visualization, including viridis, magma, inferno, plasma and simply gray. All colormaps implementations are based on the matplotlib colormaps.
spectrs is designed to replicate librosa's behaviour in the Rust ecosystem. Compatibility tests are part of the test suite, ensuring correlation between librosa's and spectrs' above 99% and relative error on relevant bands < 2%.