F0ContourShapeExtractor#

Defined in: voxatlas.features.acoustic.pitch.contour_shape

class voxatlas.features.acoustic.pitch.contour_shape.F0ContourShapeExtractor[source]#

Bases: BaseExtractor

Extract the acoustic.pitch.f0.contour_shape feature within the VoxAtlas pipeline.

This public extractor defines the reusable API for computing acoustic.pitch.f0.contour_shape from VoxAtlas structured inputs. It consumes None units and produces values aligned to frame units, making the extractor a stable pipeline node that can be cited independently of the surrounding execution machinery.

Algorithm#

The extractor discretizes local pitch movement into rising, falling, and level states using a thresholded derivative contour.

  1. Derivative computation A framewise pitch difference \(d_t = f_t - f_{t-1}\) is computed over voiced frames.

  2. State assignment Each frame is mapped to a categorical numeric code

    \[\begin{split}c_t = \begin{cases} 1 & d_t > \theta \\ 0 & |d_t| \le \theta \\ -1 & d_t < -\theta, \end{cases}\end{split}\]

    where the implementation uses a fixed threshold on the derivative magnitude.

  3. Frame packaging The discrete contour is returned at the original frame grid for later prosodic aggregation or sequence modeling.

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.contour_shape import F0ContourShapeExtractor
>>> 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, 101.0, 101.0], dtype=np.float32),
... )
>>> store.add("acoustic.pitch.f0", base)
>>> feature_input = FeatureInput(audio=None, units=None, context={"feature_store": store})
>>> out = F0ContourShapeExtractor().compute(feature_input, {})
>>> out.values.tolist()
[nan, 1.0, 0.0]
name: str = 'acoustic.pitch.f0.contour_shape'#
input_units: str | None = None#
output_units: str | None = 'frame'#
dependencies: list[str] = ['acoustic.pitch.f0']#
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 FeatureInput bundle, 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 frame unit level when applicable.

Return type:

FeatureOutput

Examples

>>> import numpy as np
>>> from voxatlas.features.acoustic.pitch.contour_shape import F0ContourShapeExtractor
>>> 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, 101.0, 101.0], dtype=np.float32),
... )
>>> store.add("acoustic.pitch.f0", base)
>>> feature_input = FeatureInput(audio=None, units=None, context={"feature_store": store})
>>> result = F0ContourShapeExtractor().compute(feature_input, {})
>>> result.unit
'frame'