pitch_garden.voters#

class pitch_garden.voters.median.MedianVoter(filter_length: int = 3)[source]#

A voter taking the median of log F0 across trackers and neighboring frames.

This is compatible with medfilt -w 1 -magic of SPTK. For each frame, the values of all trackers within the temporal window are collected. The frame is unvoiced if the unvoiced values outnumber the voiced ones; otherwise, the median of the voiced values in the log domain is taken.

vote(pitches: Mapping[str, Pitch]) → Pitch[source]#

Integrate the outputs of the trackers.

Parameters:
pitchesMapping[str, Pitch]

The outputs of the trackers keyed by the tracker names.

Returns:
outPitch

The integrated F0 contour.

class pitch_garden.voters.aligned.AlignedVoter(reference: str, voter: BaseVoter | str = 'median', voter_params: Mapping[str, Any] | None = None, *, max_shift: float = 2.0, shift_step: float = 0.1, tolerance: float = 50.0, min_overlap: int = 50)[source]#

A voter aligning the trackers to a reference tracker before voting.

For each utterance, the output of each tracker is shifted in time and corrected in frequency to match the output of the reference tracker, and the corrected outputs are integrated by the inner voter [1].

References

[1]

J. Koguchi and T. Koriyama, “Voting-based pitch estimation with temporal and frequential alignment and correlation aware selection,” in Proc. ICASSP, 2026. https://arxiv.org/abs/2602.01727

align(pitches: Mapping[str, Pitch]) → dict[str, tuple[Pitch, Alignment]][source]#

Align the outputs of the trackers to the reference.

Parameters:
pitchesMapping[str, Pitch]

The outputs of the trackers keyed by the tracker names.

Returns:
outdict[str, tuple[Pitch, Alignment]]

The aligned outputs and their corrections keyed by the tracker names. If the reference is not found, e.g., it failed in the pipeline, the outputs are not corrected.

check_trackers(names: Sequence[str]) → None[source]#

Check that the reference is one of the trackers.

Parameters:
namesSequence[str]

The names of the trackers.

Raises:
ValueError

If the reference is not found.

vote(pitches: Mapping[str, Pitch]) → Pitch[source]#

Align and integrate the outputs of the trackers.

Parameters:
pitchesMapping[str, Pitch]

The outputs of the trackers keyed by the tracker names.

Returns:
outPitch

The integrated F0 contour.

class pitch_garden.voters.base.BaseVoter[source]#

An abstract base class for voters integrating the outputs of trackers.

A voter receives the outputs of trackers keyed by the tracker names, so that tracker-specific processing such as alignment and weighting can be applied. Voters requiring training can override fit, and their learned parameters can be saved and restored via state_dict and load_state_dict.

check_trackers(names: Sequence[str]) → None[source]#

Check that the voter can be used with the trackers.

Parameters:
namesSequence[str]

The names of the trackers.

Raises:
ValueError

If the voter cannot be used with the trackers.

fit(estimates: Sequence[Mapping[str, Pitch]], references: Sequence[Pitch]) → BaseVoter[source]#

Fit the voter to training data.

Parameters:
estimatesSequence[Mapping[str, Pitch]]

The outputs of the trackers for each utterance.

referencesSequence[Pitch]

The reference F0 contours for each utterance.

Returns:
outBaseVoter

The fitted voter itself.

load_state_dict(state: Mapping[str, Any]) → None[source]#

Restore the learned parameters.

Parameters:
stateMapping[str, Any]

The learned parameters.

state_dict() → dict[str, Any][source]#

Get the learned parameters.

Returns:
outdict[str, Any]

The learned parameters, which must be JSON serializable.

abstractmethod vote(pitches: Mapping[str, Pitch]) → Pitch[source]#

Integrate the validated outputs of the trackers.

Parameters:
pitchesMapping[str, Pitch]

The outputs of the trackers keyed by the tracker names.

Returns:
outPitch

The integrated F0 contour.