nemo_curator.stages.audio.metrics.wer
nemo_curator.stages.audio.metrics.wer
WER / CER computation stage.
Module Contents
Classes
API
Bases: ProcessingStage[AudioTask, AudioTask]
Stage that computes Word Error Rate (WER), CER, edge CER, and optionally PNC WER/CER. This stage cleans the text and normalizes it using NeMo text processing (numbers to words, etc).
Operates on segments within each entry (audio_segment[“hypothesis_text_key”] vs audio_segment[“reference_text_key”]). If “segments” is not in the data entry, the stage will compute WER, CER, edge CER, and optionally PNC WER/CER for the entire entry.
Parameters:
Language of the text. Defaults to “en”.
Key to the hypothesis text. Defaults to “text”.
Key to the reference text. Defaults to “text”.
Number of words to use for normalization. Defaults to 200.
Number of words to look back for normalization. Defaults to 5.
Whether to compute PNC WER/CER. Defaults to False.
Punctuation characters to use for normalization. Defaults to special punctuation string.
Length of the edge to compute CER. Defaults to 12.
Key for the segments in the manifest. Defaults to “segments”.
Returns:
The same data as in the input data, but with WER, CER, edge CER, and optionally PNC WER/CER added to each segment.
Clean text by removing invalid characters.
Calculate character rate (chars per second).
Compute WER, CER, edge CER, and optionally PNC WER/CER per segment.
Calculate word rate (words per second).
Normalize and clean text. Returns (cleaned_with_punct, cleaned_without_punct).
Normalize text using NeMo text processing (numbers to words, etc).
Compute WER, CER, edge CER, and optionally PNC WER/CER per segment.
Setup stage.
Strip spaces before punctuation characters.
OR-shaped validation: segments OR top-level text keys must be present.
Bases: ProcessingStage[AudioTask, AudioTask]
Compute pairwise word-error-rate (WER) as a percentage for each pair of text and pred_text.
WER is measured between data[self.text_key] and data[self.pred_text_key]
and stored as a percentage (e.g. 5.0 means 5% WER).
Parameters:
Key for the utterance transcript. Defaults to “text”.
Key for the ASR predictions. Defaults to “pred_text”.
Key to store the computed WER percentage. Defaults to “wer_pct”.
Compute WER percentage between hypothesis and reference text.