Commit a24435dc authored by Anthony Larcher's avatar Anthony Larcher
Browse files

add noise

parent 78266092
......@@ -315,6 +315,8 @@ class SpkSet(Dataset):
dataset = yaml.load(fh, Loader=yaml.FullLoader)
self.transform_number = transform_number
self.noise_root_db = dataset["train"]["transformation"]["noise_root_db"]
self.data_path = dataset["data_root_directory"]
self.sample_rate = int(dataset["sample_rate"])
......@@ -485,7 +487,7 @@ class SpkSet(Dataset):
speech, speech_fs = torchaudio.load(f"{self.data_path}/{current_segment['file_id']}{self.data_file_extension}",
frame_offset=start_frame,
num_frames=stop_frame)
num_frames=self.sample_number)
# Select the data augmentation randomly
aug_idx = numpy.random.randint(0,len(self.transform), self.transform_number)
......@@ -496,10 +498,10 @@ class SpkSet(Dataset):
snr_db = random.choice(self.transformation["noise_snr"])
# Pick a file name from the noise_df
noise_fn = random.choice(self.noise_df)
noise_fn = self.noise_root_db + "/" + random.choice(self.noise_df) + ".wav"
noise, noise_fs = torchaudio.load(noise_fn,
frame_offset=0,
num_frames=int(current_segment['duration'] * self.sample_rate))
num_frames=speech.shape[1])
speech_power = speech.norm(p=2)
noise_power = noise.norm(p=2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment