def process(metadata: AudioClipMetadata): new_path = audio_folder / metadata.path.with_suffix('.wav').name if not new_path.exists(): audio_data = silent_load(str(metadata.path), self.dataset.sr, self.dataset.mono) soundfile.write(str(new_path), audio_data, self.dataset.sr) metadata.path = new_path
def process(metadata: AudioClipMetadata): new_path = (audio_folder / metadata.audio_id).with_suffix(".wav") # TODO:: process function should also take in sample (AudioClipExample) # and use sample.audio_data when metadata.path does not exist if not new_path.exists(): audio_data = silent_load(str(metadata.path), self.dataset.sr, self.dataset.mono) soundfile.write(str(new_path), audio_data, self.dataset.sr) metadata.path = new_path
def __getitem__(self, idx) -> ClassificationClipExample: metadata = self.metadata_list[idx] audio_data = silent_load(str(metadata.path), self.sr, self.mono) return ClassificationClipExample( metadata=metadata, audio_data=torch.from_numpy(audio_data), sample_rate=self.sr, label=self.label_map[metadata.transcription])
def __getitem__(self, idx) -> WakeWordClipExample: metadata = self.metadata_list[idx] audio_data = silent_load(str(metadata.path), self.sr, self.mono) return WakeWordClipExample( metadata=metadata, audio_data=torch.from_numpy(audio_data), sample_rate=self.sr, label_data=self.frame_labeler.compute_frame_labels(metadata))
def __getitem__(self, idx) -> AudioClipExample: metadata = self.metadata_list[idx] audio_data = silent_load(str(metadata.path), self.sr, self.mono) return AudioClipExample(metadata=metadata, audio_data=torch.from_numpy(audio_data), sample_rate=self.sr)