nemo_curator.stages.audio.tagging.prepare_module_segments
nemo_curator.stages.audio.tagging.prepare_module_segments
Prepare Module Segments Stage. Merges adjacent same-speaker segments and splits by duration, punctuation, and bandwidth.
Module Contents
Classes
API
Bases: ProcessingStage[AudioTask, AudioTask]
Stage that prepares segments for TTS or ASR by merging and splitting based on duration, punctuation, and bandwidth.
Merges adjacent same-speaker segments, then splits by max duration, pauses, terminal punctuation, and bandwidth changes.
Parameters:
Target module: “tts” (single-speaker segments) or “asr” (multi-speaker ok).
Minimum segment duration in seconds. Defaults to 5.0.
Maximum segment duration in seconds. Defaults to 20.0.
Max pause between words to stay in same segment (TTS).
Key for segment text. Defaults to “text”.
Key for word-level alignments in segments. Defaults to “words”.
Punctuation that ends an utterance (e.g. ”.!?”). Defaults to CJK/Latin punct string.
Ratio of content to segment at terminal punctuation (0-1).
If True, split only at punctuation; else also by duration. Defaults to False.
Stage name for logging and output files. Defaults to “PrepareModuleSegments”.
Returns:
The same data as in the input manifest, but with the new segments added to the metadata.
Write new segment list into metadata with text, words, and metrics keys.
This method gets the words list from all the speaker segments
Parameters:
A dictionary containing the metadata of the audio file
Returns: list[dict[str, Any]]
A list of words with the following fields:
- word: The word
- start: The start time of the word
- end: The end time of the word
- speaker: The speaker of the word
- pesq_squim: The PESQ score of the word if available
- stoi_squim: The STOI score of the word if available
- sisdr_squim: The SI-SDR score of the word if available
- bandwidth: The bandwidth of the word if available
Return False if segment is a single over-long word or has no text.
Prepare ASR segments (multi-speaker per segment allowed).
Prepare TTS segments (single speaker per segment).
Process one entry: build words from segments, then prepare TTS or ASR segments.
Split one segment by duration, pause, and bandwidth (TTS) or duration only (ASR).
Split segment at terminal punctuation; fallback to duration split if none, or when over max_duration.