nemo_curator.stages.audio.text_filtering
nemo_curator.stages.audio.text_filtering
Audio transcript filtering stages.
Submodules
nemo_curator.stages.audio.text_filtering.abbreviation_concatnemo_curator.stages.audio.text_filtering.disfluency_wer_guardnemo_curator.stages.audio.text_filtering.regex_substitutionnemo_curator.stages.audio.text_filtering.scriptio_continuanemo_curator.stages.audio.text_filtering.select_best_predictionnemo_curator.stages.audio.text_filtering.text_metricsnemo_curator.stages.audio.text_filtering.whisper_hallucination
Package Contents
Classes
API
Bases: ProcessingStage[AudioTask, AudioTask]
Concatenate spaced single-letter abbreviations in a transcript.
Bases: ProcessingStage[AudioTask, AudioTask]
Restore the original prediction when disfluency removal diverges.
The stage compares ref_text_key with the disfluency-cleaned text at
hyp_text_key. It uses character error rate (CER) for languages written
without word-separating spaces and word error rate (WER) otherwise. If the
selected error rate exceeds max_wer_pct, the cleaned prediction is
replaced with the original prediction.
The selected rate is stored in the compatibility field wer_key even
when CER is used, matching the reference pipeline contract.
Bases: ProcessingStage[AudioTask, AudioTask]
Apply an ordered YAML list of regex substitutions to one transcript field.
The YAML document must be a list. Each rule must define string
pattern and repl values and may define a non-negative integer
count limit. Rules run in file order before whitespace is collapsed.
Rows carrying an existing skip reason are not normalized. The empty-result
skip is set only when cleaning removes non-whitespace input; already-empty
input remains unskipped.
Bases: ProcessingStage[AudioTask, AudioTask]
Choose one stable transcript from primary, recovery, or reference text.
Selection is ordered so explicit reference policies run before model
recovery. Short Qwen-Omni clips can use reference text to avoid known
sub-second hallucinations, and force_reference can make reference text
authoritative for datasets whose model output is not trusted. Otherwise,
the stage handles unsupported languages, recovered fallback predictions,
reference recovery, cross-model agreement, and the normal primary result.
Cross-model agreement uses character error rate (CER) for languages written
without word-separating spaces and word error rate (WER) otherwise. The
selected metric is recorded in metric_key.
asr_text_key is a compatibility alias that overrides
fallback_text_key when supplied.
Bases: ProcessingStage[AudioTask, AudioTask]
Flag transcripts that show common ASR hallucination patterns.
Four independent checks run, and any single hit flags the row:
- Repeated n-grams: the unique-word ratio falls to or below
unique_words_threshold, the signature of a decoder stuck in a loop. - Long word: a word at or over the language-appropriate absolute length
bar, or one much longer than the next-longest word by
long_word_rel_threshold. - Phrase match: the transcript is a known hallucination phrase or an
approved continuation from
common_hall_file(think “Thank you for watching” over silence). - High char rate: characters per second exceed
max_char_rate, an impossible speaking rate, which catches dense text confabulated over a very short clip.
Repeated-word and long-word checks are disabled for languages written without word-separating spaces because whitespace tokenization treats an entire utterance as one word. Phrase and character-rate checks remain active for those languages.
When flagged, skip_me_key is set to "Hallucination:{name}" so the
originating instance stays identifiable. An existing non-hallucination flag
from some other filter is never clobbered. Setting overwrite=True turns
the stage into a re-check that can also clear a previous hallucination
flag when a second-pass transcript now looks clean, which is how an ASR
recovery pass promotes its result.
recovery_value is a caller-selected note written only when
overwrite=True clears an existing hallucination flag. For example,
recovery_value="Recovered:ASR" produces the note "recovered:asr".
Leaving it empty produces "recovered".
Run the bundled YAML from the Curator repository root over a JSONL manifest
that already contains pred_text, _skipme, and duration:
.. code-block:: bash
python nemo_curator/config/run.py
—config-path ../../tutorials/audio/whisper_hallucination
—config-name pipeline
manifest_path=tests/fixtures/audio/text_filtering/whisper_hallucination_input.jsonl
output_path=/tmp/whisper_hallucination_output.jsonl