SpectralSpreadExtractor#
Defined in: voxatlas.features.acoustic.spectral.spread
- class voxatlas.features.acoustic.spectral.spread.SpectralSpreadExtractor[source]#
Bases:
BaseExtractorExtract the
acoustic.spectral.spreadfeature within the VoxAtlas pipeline.This public extractor defines the reusable API for computing
acoustic.spectral.spreadfrom 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 measures second-moment dispersion of spectral energy around the centroid.
Centroid preparation The spectrum and frequency axis are combined with either a supplied or internally computed centroid \(C_t\).
Spread computation The spread is
\[\mathrm{Spread}_t = \sqrt{\frac{\sum_k S_{t,k}(f_k-C_t)^2}{\sum_k S_{t,k}}}.\]Packaging The resulting contour remains aligned to the source spectrum frames.
Notes
This extractor declares the upstream dependencies [‘acoustic.spectral.spectrum’] and is executed only after those features are available in the pipeline feature store.
Examples
>>> import numpy as np >>> from voxatlas.features.acoustic.spectral.spread import SpectralSpreadExtractor >>> from voxatlas.features.feature_input import FeatureInput >>> from voxatlas.features.feature_output import MatrixFeatureOutput >>> from voxatlas.pipeline.feature_store import FeatureStore >>> store = FeatureStore() >>> spectrum = MatrixFeatureOutput( ... feature="acoustic.spectral.spectrum", ... unit="frame", ... time=np.array([0.0, 0.01], dtype=np.float32), ... frequency=np.array([0.0, 1000.0, 2000.0], dtype=np.float32), ... values=np.array([[0.0, 1.0, 0.0], [1.0, 1.0, 1.0]], dtype=np.float32), ... ) >>> store.add("acoustic.spectral.spectrum", spectrum) >>> feature_input = FeatureInput(audio=None, units=None, context={"feature_store": store}) >>> out = SpectralSpreadExtractor().compute(feature_input, {}) >>> out.values.shape (2,) >>> float(out.values[0]) 0.0 >>> round(float(out.values[1]), 1) 816.5
- name: str = 'acoustic.spectral.spread'#
- input_units: str | None = None#
- output_units: str | None = 'frame'#
- dependencies: list[str] = ['acoustic.spectral.spectrum']#
- default_config: dict = {}#
- 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.features.acoustic.spectral.spread import SpectralSpreadExtractor >>> from voxatlas.features.feature_input import FeatureInput >>> from voxatlas.features.feature_output import MatrixFeatureOutput >>> from voxatlas.pipeline.feature_store import FeatureStore >>> store = FeatureStore() >>> spectrum = MatrixFeatureOutput( ... feature="acoustic.spectral.spectrum", ... unit="frame", ... time=np.array([0.0], dtype=np.float32), ... frequency=np.array([0.0, 1000.0, 2000.0], dtype=np.float32), ... values=np.array([[0.0, 1.0, 0.0]], dtype=np.float32), ... ) >>> store.add("acoustic.spectral.spectrum", spectrum) >>> feature_input = FeatureInput(audio=None, units=None, context={"feature_store": store}) >>> result = SpectralSpreadExtractor().compute(feature_input, {}) >>> result.unit 'frame'