pitch_garden.metrics#
The module for evaluating F0 contours.
The following metrics are provided:
VDE (Voicing Decision Error): the ratio of frames with wrong voicing decisions.
Voicing precision, recall, and F1, where voiced frames are regarded as positive.
GPE (Gross Pitch Error): the ratio of frames whose relative error exceeds 20% among the frames voiced in both.
FPE (Fine Pitch Error): the standard deviation of the error in cents among the frames voiced in both without gross errors.
RPA (Raw Pitch Accuracy): the ratio of reference voiced frames estimated within 50 cents.
RCA (Raw Chroma Accuracy): RPA ignoring octave errors.
OA (Overall Accuracy): the ratio of frames that are correctly unvoiced or voiced in both with errors within 50 cents.
Pitch F1: the harmonic mean of the pitch precision and recall at 50 cents, where a hit is a frame voiced in both with an error within 50 cents.
- pitch_garden.metrics.evaluate(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None) dict[str, float][source]#
Calculate all metrics with their default settings.
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- Returns:
- outdict[str, float]
The metrics keyed by their names.
- pitch_garden.metrics.vde(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None) float[source]#
Calculate VDE (Voicing Decision Error).
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- Returns:
- outfloat
The ratio of frames whose voicing decision is wrong.
- pitch_garden.metrics.voicing_scores(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None) dict[str, float][source]#
Calculate the precision, recall, and F1 of the voicing decision.
The voiced frames are regarded as positive.
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- Returns:
- outdict[str, float]
The ‘precision’, ‘recall’, and ‘f1’.
- pitch_garden.metrics.gpe(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None, threshold: float = 0.2) float[source]#
Calculate GPE (Gross Pitch Error).
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- thresholdfloat, optional
The relative error regarded as gross.
- Returns:
- outfloat
The ratio of gross errors among the frames voiced in both.
- pitch_garden.metrics.fpe(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None, threshold: float = 0.2) float[source]#
Calculate FPE (Fine Pitch Error).
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- thresholdfloat, optional
The relative error regarded as gross, which is excluded.
- Returns:
- outfloat
The standard deviation of the error in cents among the frames voiced in both without gross errors.
- pitch_garden.metrics.rpa(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None, tolerance: float = 50.0) float[source]#
Calculate RPA (Raw Pitch Accuracy).
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- tolerancefloat, optional
The tolerance in cents.
- Returns:
- outfloat
The ratio of reference voiced frames estimated within the tolerance.
- pitch_garden.metrics.rca(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None, tolerance: float = 50.0) float[source]#
Calculate RCA (Raw Chroma Accuracy), i.e., RPA ignoring octave errors.
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- tolerancefloat, optional
The tolerance in cents.
- Returns:
- outfloat
The ratio of reference voiced frames estimated within the tolerance after octave folding.
- pitch_garden.metrics.oa(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None, tolerance: float = 50.0) float[source]#
Calculate OA (Overall Accuracy).
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- tolerancefloat, optional
The tolerance in cents.
- Returns:
- outfloat
The ratio of frames that are correctly unvoiced or voiced in both with the estimated F0 within the tolerance.
- pitch_garden.metrics.f1_score(reference: Pitch | ndarray, estimate: Pitch | ndarray, mask: ndarray | None = None, tolerance: float = 50.0) float[source]#
Calculate the pitch F1 score.
A frame is a hit if both are voiced and the error is within the tolerance. The precision and recall are the ratios of hits to the estimated and reference voiced frames, respectively.
- Parameters:
- referencePitch | np.ndarray
The reference F0 in Hz (unvoiced: 0).
- estimatePitch | np.ndarray
The estimated F0 in Hz (unvoiced: 0).
- masknp.ndarray | None, optional
The boolean array that is True for the frames to be evaluated.
- tolerancefloat, optional
The tolerance in cents.
- Returns:
- outfloat
The pitch F1 score.