Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion noisekit/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ def extract_audio_and_text(sample: dict) -> tuple[np.ndarray, int, str]:
else:
raise ValueError("Audio sample has neither 'bytes' nor 'path'.")

array = np.asarray(array, dtype=np.float32)
if array.ndim == 2:
array = array.mean(axis=1) # (samples, channels) → (samples,) for mono-only metrics

text = (
sample.get("text")
or sample.get("sentence")
or sample.get("transcription")
or sample.get("normalized_text")
or ""
)
return np.asarray(array, dtype=np.float32), int(sr), str(text).strip()
return array, int(sr), str(text).strip()