feat(audio-tagging): output control + in-memory handoff + agent-ready contracts - #2339
feat(audio-tagging): output control + in-memory handoff + agent-ready contracts#2339shubhamNvidia wants to merge 1 commit into
Conversation
Adds describe() contracts to the tagging stages (ASR-align, merge-alignment-diarization, prepare-module-segments, resample, split, and the text normalizers) so a planner can tell what each reads and writes before running it. Depends on the agent-ready foundation (nemo_curator/stages/audio/_agent/), which must merge first. Signed-off-by: Shubham Bhawsar <shbhawsar@nvidia.com>
Greptile SummaryThis PR adds agent-readable contracts and configurable metadata keys across audio-tagging stages, plus in-memory resampling, stable resample naming, configurable split destinations, and configurable text-output suffixes.
Confidence Score: 4/5The PR should not merge until A remote split destination can advertise cloud chunk URLs without placing audio at those URLs, breaking the downstream split-and-align flow; the in-memory resample path also leaks a temporary file when waveform loading fails. Files Needing Attention: nemo_curator/stages/audio/tagging/split.py, nemo_curator/stages/audio/tagging/resample_audio.py Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Input[File or in-memory waveform] --> Resample[ResampleAudioStage]
Resample -->|write_to_disk| ResampledFile[Resampled file]
Resample -->|keep_waveform_in_task| Waveform[Waveform and sample rate]
ResampledFile --> Split[SplitLongAudioStage]
Split --> Chunks[Split chunk files and metadata]
Chunks --> ASR[NeMoASRAlignerStage]
ASR --> Join[JoinSplitAudioMetadataStage]
Join --> Output[Joined text and alignment]
Reviews (1): Last reviewed commit: "feat(audio-tagging): make tagging stages..." | Re-trigger Greptile |
| if self.output_dir is None: | ||
| split_filepath = f"{parent_url}/{split_name}" if parent_url else split_name | ||
| split_resolved = f"{resolved_parent}/{split_name}" if resolved_parent else split_name | ||
| return split_filepath, split_resolved |
There was a problem hiding this comment.
If output_dir is a remote URL, _split_paths advertises that URL but passes its protocol-stripped path to torchaudio.save, causing chunks to be written locally or fail while downstream ASR reads nonexistent remote objects.
Knowledge Base Used: Audio curation stages
| if self.keep_waveform_in_task: | ||
| waveform, sample_rate = load_audio_file(output_audio_path, mono=False) | ||
| data_entry[self.waveform_key] = waveform | ||
| data_entry[self.sample_rate_key] = sample_rate | ||
| duration = get_audio_duration(output_audio_path) | ||
| data_entry[self.duration_key] = duration | ||
| if not self.write_to_disk: | ||
| try: # noqa: SIM105 | ||
| os.remove(output_audio_path) | ||
| except OSError: |
There was a problem hiding this comment.
Temporary output leaks on failure
With write_to_disk=False, an exception from load_audio_file occurs before output_audio_path is removed, leaving one converted temporary file behind for every failed in-memory handoff.
Knowledge Base Used: Audio curation stages
Contracts:
describe()+*_keyparams across the tagging stages (ASR-align, merge-alignment-diarization, prepare-module-segments, resample, split, and the Chinese-conversion / inverse-text-normalization text stages). Includes theSplitASRAlignJoinStagecomposite contract, so the planner can see through the composite to the sub-stages it expands into rather than treating it as an opaque box.New functionality
In-memory handoff on resample (
keep_waveform_in_task,write_to_disk) — a resample feeding an ASR stage no longer has to land on disk first.Stable output naming on resample (fixes duplicate and stale files). The output was named after the input path. That broke in three ways, all now covered by tests:
The output is now named from a digest of the audio content plus the settings being applied (
target_sample_rate,target_nchannels,target_format). Rows that already carry a real input path keep the name they have always had — the digest only stands in where the path cannot.update_audio_filepathon resample — choose whether downstream stages see the resampled file or the original path, instead of that being decided for you.Configurable outputs —
output_diron split (where the chunks go) andoutput_suffixon the text stages (_ITN,_simplified), so a pipeline can direct these without editing code.Depends on the agent-ready foundation, #2332 — that must merge first (this branch imports
nemo_curator/stages/audio/_agent/, so CI here stays red until it lands).