> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/curator/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/curator/_mcp/server.

# nemo_curator.stages.audio.metrics.wer

WER / CER computation stage.

## Module Contents

### Classes

| Name                                                                                | Description                                                                                  |
| ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| [`ComputeWERStage`](#nemo_curator-stages-audio-metrics-wer-ComputeWERStage)         | Stage that computes Word Error Rate (WER), CER, edge CER, and optionally PNC WER/CER.        |
| [`GetPairwiseWerStage`](#nemo_curator-stages-audio-metrics-wer-GetPairwiseWerStage) | Compute pairwise word-error-rate (WER) as a percentage for each pair of text and pred\_text. |

### API

```python
class nemo_curator.stages.audio.metrics.wer.ComputeWERStage(
    language: str = 'en',
    hypothesis_text_key: str = 'text',
    reference_text_key: str = 'text_ref',
    num_words_threshold: int = 200,
    num_words_look_back: int = 5,
    compute_pnc_wer: bool = False,
    pnc_chars: str = '،؟.、？¿!,?।',
    edge_length: int = 12,
    segments_key: str = 'segments',
    name: str = 'ComputeWER',
    _normalizer: typing.Any = None
)
```

Dataclass

**Bases:** [ProcessingStage\[AudioTask, AudioTask\]](/nemo-curator/nemo_curator/stages/base#nemo_curator-stages-base-ProcessingStage)

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`** `str` — default: 'en'

Language of the text. Defaults to "en".

---

**`hypothesis_text_key`** `str` — default: 'text'

Key to the hypothesis text. Defaults to "text".

---

**`reference_text_key`** `str` — default: 'text\_ref'

Key to the reference text. Defaults to "text".

---

**`num_words_threshold`** `int` — default: 200

Number of words to use for normalization. Defaults to 200.

---

**`num_words_look_back`** `int` — default: 5

Number of words to look back for normalization. Defaults to 5.

---

**`compute_pnc_wer`** `bool` — default: False

Whether to compute PNC WER/CER. Defaults to False.

---

**`pnc_chars`** `str` — default: '،؟.、？¿!,?।'

Punctuation characters to use for normalization. Defaults to special punctuation string.

---

**`edge_length`** `int` — default: 12

Length of the edge to compute CER. Defaults to 12.

---

**`segments_key`** `str` — default: 'segments'

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.

**`_normalizer`** `Any = field(default=None, repr=False)`

---

**`compute_pnc_wer`** `bool = False`

---

**`edge_length`** `int = 12`

---

**`hypothesis_text_key`** `str = 'text'`

---

**`language`** `str = 'en'`

---

**`name`** `str = 'ComputeWER'`

---

**`num_words_look_back`** `int = 5`

---

**`num_words_threshold`** `int = 200`

---

**`pnc_chars`** `str = '،؟.、？¿!,?।'`

---

**`reference_text_key`** `str = 'text_ref'`

---

**`segments_key`** `str = 'segments'`

---

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.__post_init__() -> None
```

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.clean_text(
    text: str,
    retain_pncs: bool = True
) -> str
```

Clean text by removing invalid characters.

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.get_char_rate(
    text: str,
    duration: float
) -> float
```

Calculate character rate (chars per second).

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.get_wer(
    audio_segment: dict[str, typing.Any]
) -> None
```

Compute WER, CER, edge CER, and optionally PNC WER/CER per segment.

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.get_word_rate(
    text: str,
    duration: float
) -> float
```

Calculate word rate (words per second).

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.inputs() -> tuple[list[str], list[str]]
```

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.normalize_and_clean_text(
    text: str
) -> tuple[str, str]
```

Normalize and clean text. Returns (cleaned\_with\_punct, cleaned\_without\_punct).

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.normalize_text(
    text: str
) -> str
```

Normalize text using NeMo text processing (numbers to words, etc).

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.outputs() -> tuple[list[str], list[str]]
```

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.process(
    task: nemo_curator.tasks.AudioTask
) -> nemo_curator.tasks.AudioTask
```

Compute WER, CER, edge CER, and optionally PNC WER/CER per segment.

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.setup(
    _worker_metadata: nemo_curator.backends.base.WorkerMetadata | None = None
) -> None
```

Setup stage.

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.strip_spaces_before_punctuations(
    text: str
) -> str
```

Strip spaces before punctuation characters.

```python
nemo_curator.stages.audio.metrics.wer.ComputeWERStage.validate_input(
    task: nemo_curator.tasks.AudioTask
) -> bool
```

OR-shaped validation: segments OR top-level text keys must be present.

```python
class nemo_curator.stages.audio.metrics.wer.GetPairwiseWerStage(
    name: str = 'GetPairwiseWerStage',
    text_key: str = 'text',
    pred_text_key: str = 'pred_text',
    wer_key: str = 'wer_pct'
)
```

Dataclass

**Bases:** [ProcessingStage\[AudioTask, AudioTask\]](/nemo-curator/nemo_curator/stages/base#nemo_curator-stages-base-ProcessingStage)

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:**

**`text_key`** `str` — default: 'text'

Key for the utterance transcript. Defaults to "text".

---

**`pred_text_key`** `str` — default: 'pred\_text'

Key for the ASR predictions. Defaults to "pred\_text".

---

**`wer_key`** `str` — default: 'wer\_pct'

Key to store the computed WER percentage. Defaults to "wer\_pct".

---

**`name`** `str = 'GetPairwiseWerStage'`

---

**`pred_text_key`** `str = 'pred_text'`

---

**`text_key`** `str = 'text'`

---

**`wer_key`** `str = 'wer_pct'`

---

```python
nemo_curator.stages.audio.metrics.wer.GetPairwiseWerStage.inputs() -> tuple[list[str], list[str]]
```

```python
nemo_curator.stages.audio.metrics.wer.GetPairwiseWerStage.outputs() -> tuple[list[str], list[str]]
```

```python
nemo_curator.stages.audio.metrics.wer.GetPairwiseWerStage.process(
    task: nemo_curator.tasks.AudioTask
) -> nemo_curator.tasks.AudioTask
```

Compute WER percentage between hypothesis and reference text.