STFTSpectrogramExtractor#
Defined in: voxatlas.features.acoustic.spectrogram.stft
- class voxatlas.features.acoustic.spectrogram.stft.STFTSpectrogramExtractor[source]#
Bases:
BaseExtractorExtract the
acoustic.spectrogram.stftfeature within the VoxAtlas pipeline.This public extractor defines the reusable API for computing
acoustic.spectrogram.stftfrom 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 exposes the short-time Fourier transform magnitude as a matrix-valued public API.
Windowed analysis Frames are extracted from the waveform according to the configured frame size and hop.
Fourier transform For each frame, the discrete Fourier transform is computed and stored as
\[X_t(k) = \sum_{n=0}^{N-1} x_t[n]e^{-j2\pi kn/N}.\]Magnitude packaging VoxAtlas stores \(|X_t(k)|\) together with explicit time and frequency axes so later features can be defined transparently.
Examples
>>> import numpy as np >>> from voxatlas.audio.audio import Audio >>> from voxatlas.features.acoustic.spectrogram.stft import STFTSpectrogramExtractor >>> 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 = STFTSpectrogramExtractor.default_config.copy() >>> out = STFTSpectrogramExtractor().compute(feature_input, params) >>> (out.values.shape[0] == len(out.time), out.values.shape[1] == len(out.frequency)) (True, True)
- name: str = 'acoustic.spectrogram.stft'#
- input_units: str | None = None#
- output_units: str | None = 'frame'#
- dependencies: list[str] = []#
- default_config: dict = {'fmax': None, 'fmin': 0.0, 'frame_length': 0.025, 'frame_step': 0.01, 'n_mels': 40}#
- 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.spectrogram.stft import STFTSpectrogramExtractor >>> 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 = STFTSpectrogramExtractor.default_config.copy() >>> result = STFTSpectrogramExtractor().compute(feature_input, params) >>> result.unit 'frame'