F0SlopeExtractor#
Defined in: voxatlas.features.acoustic.pitch.slope
- class voxatlas.features.acoustic.pitch.slope.F0SlopeExtractor[source]#
Bases:
BaseExtractorExtract the
acoustic.pitch.f0.slopefeature within the VoxAtlas pipeline.This public extractor defines the reusable API for computing
acoustic.pitch.f0.slopefrom 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 summarizes local pitch trajectory shape by fitting a straight line inside a sliding voiced window around each frame.
Voiced-frame selection Only finite, positive \(f_0\) values are retained. Frames with insufficient voiced support are left undefined.
Local regression For each frame, the method estimates the least-squares slope
\[\hat\beta = \frac{\sum_i (t_i-\bar t)(f_i-\bar f)}{\sum_i (t_i-\bar t)^2},\]over the voiced samples inside the configured neighborhood.
Frame-level output The resulting slope is returned at frame resolution, making the feature suitable for intonational rise-fall analyses and downstream contour-shape abstractions.
Notes
This extractor declares the upstream dependencies [‘acoustic.pitch.f0’] and is executed only after those features are available in the pipeline feature store.
Examples
>>> import numpy as np >>> from voxatlas.features.acoustic.pitch.slope import F0SlopeExtractor >>> from voxatlas.features.feature_input import FeatureInput >>> from voxatlas.features.feature_output import VectorFeatureOutput >>> from voxatlas.pipeline.feature_store import FeatureStore >>> store = FeatureStore() >>> base = VectorFeatureOutput( ... feature="acoustic.pitch.f0", ... unit="frame", ... time=np.array([0.0, 0.01, 0.02], dtype=np.float32), ... values=np.array([100.0, 110.0, 120.0], dtype=np.float32), ... ) >>> store.add("acoustic.pitch.f0", base) >>> feature_input = FeatureInput(audio=None, units=None, context={"feature_store": store}) >>> out = F0SlopeExtractor().compute(feature_input, {"window": 3}) >>> out.values.shape == base.values.shape True
- name: str = 'acoustic.pitch.f0.slope'#
- input_units: str | None = None#
- output_units: str | None = 'frame'#
- dependencies: list[str] = ['acoustic.pitch.f0']#
- default_config: dict = {'window': 5}#
- 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.pitch.slope import F0SlopeExtractor >>> from voxatlas.features.feature_input import FeatureInput >>> from voxatlas.features.feature_output import VectorFeatureOutput >>> from voxatlas.pipeline.feature_store import FeatureStore >>> store = FeatureStore() >>> base = VectorFeatureOutput( ... feature="acoustic.pitch.f0", ... unit="frame", ... time=np.array([0.0, 0.01, 0.02], dtype=np.float32), ... values=np.array([100.0, 110.0, 120.0], dtype=np.float32), ... ) >>> store.add("acoustic.pitch.f0", base) >>> feature_input = FeatureInput(audio=None, units=None, context={"feature_store": store}) >>> result = F0SlopeExtractor().compute(feature_input, {"window": 3}) >>> result.unit 'frame'