SpectrumExtractor#
Defined in: voxatlas.features.acoustic.spectral.spectrum
- class voxatlas.features.acoustic.spectral.spectrum.SpectrumExtractor[source]#
Bases:
BaseExtractorExtract the
acoustic.spectral.spectrumfeature within the VoxAtlas pipeline.This public extractor defines the reusable API for computing
acoustic.spectral.spectrumfrom VoxAtlas structured inputs. It consumesNoneunits and produces values aligned toframeunits, making the extractor a stable pipeline node that can be cited independently of the surrounding execution machinery.Algorithm#
The extractor returns the frame-by-frequency magnitude spectrum computed from a short-time Fourier transform.
STFT analysis The waveform is windowed and transformed framewise.
Magnitude projection For frame \(t\) and frequency bin \(k\), the stored value is
\[S_{t,k} = |X_t(k)|.\]Matrix packaging The resulting matrix, together with time and frequency axes, is emitted as a
MatrixFeatureOutputfor downstream spectral descriptors.
Examples
>>> import numpy as np >>> from voxatlas.audio.audio import Audio >>> from voxatlas.features.acoustic.spectral.spectrum import SpectrumExtractor >>> from voxatlas.features.feature_input import FeatureInput >>> audio = Audio(waveform=np.zeros(1600, dtype=np.float32), sample_rate=16000) >>> feature_input = FeatureInput(audio=audio, units=None, context={}) >>> params = SpectrumExtractor.default_config.copy() >>> out = SpectrumExtractor().compute(feature_input, params) >>> out.unit 'frame'
- name: str = 'acoustic.spectral.spectrum'#
- input_units: str | None = None#
- output_units: str | None = 'frame'#
- dependencies: list[str] = []#
- default_config: dict = {'frame_length': 0.025, 'frame_step': 0.01, 'window': 'hann'}#
- compute(feature_input, params)[source]#
Compute the extractor output for a single pipeline invocation.
This method is the reusable execution entry point for the extractor. It receives the standard
FeatureInputbundle, applies the configured algorithm, and returns feature values aligned to the extractor output units for storage in the pipeline feature store.- Parameters:
feature_input (object) – Structured extractor input bundling audio, hierarchical units, and execution context for this feature computation.
params (object) – Resolved feature configuration for this invocation. Keys are feature-specific and merged from defaults and pipeline settings.
- Returns:
Structured output aligned to the
frameunit level when applicable.- Return type:
FeatureOutput
Examples
>>> import numpy as np >>> from voxatlas.audio.audio import Audio >>> from voxatlas.features.acoustic.spectral.spectrum import SpectrumExtractor >>> from voxatlas.features.feature_input import FeatureInput >>> audio = Audio(waveform=np.zeros(1600, dtype=np.float32), sample_rate=16000) >>> feature_input = FeatureInput(audio=audio, units=None, context={}) >>> params = SpectrumExtractor.default_config.copy() >>> result = SpectrumExtractor().compute(feature_input, params) >>> result.values.ndim 2