Commit 65e4ef78 authored by Anthony Larcher's avatar Anthony Larcher
Browse files

secure SideSet

parent 474d9d5b
......@@ -115,10 +115,10 @@ class AddNoise(object):
#
noise = normalize(noise)
noises.append(noise.squeeze()[:, None])
noises.append(noise.squeeze())
# concatenate
noise = numpy.vstack(noises).squeeze()
noise = numpy.hstack(noises)
# select SNR at random
snr = (self.snr_max - self.snr_min) * numpy.random.random_sample() + self.snr_min
......
......@@ -472,12 +472,20 @@ class SideSet(Dataset):
:return:
"""
# Check the size of the file
nfo = soundfile.info("{self.data_path}/{self.sessions.iloc[index]['file_id']}{self.data_file_extension}")
start_frame = int(self.sessions.iloc[index]['start'] * self.sample_rate)
if start_frame + self.sample_number >= nfo.frames:
start_frame = numpy.min(nfo.frames - self.sample_number - 1)
stop_frame = start_frame + self.sample_number
sig, _ = soundfile.read(f"{self.data_path}/{self.sessions.iloc[index]['file_id']}{self.data_file_extension}",
start=int(self.sessions.iloc[index]['start'] * self.sample_rate),
stop=int(self.sessions.iloc[index]['start'] * self.sample_rate) + self.sample_number
start=start_frame,
stop=stop_frame
)
sig += 0.0001 * numpy.random.randn(sig.shape[0])
speaker_idx = self.sessions.iloc[index]["speaker_idx"]
if self.transformation["pipeline"]:
......@@ -519,13 +527,13 @@ def createSideSets(data_set_yaml,
# TODO SPLIT THE COROPORA OR USE THE TWO PROVIDED DATAFRAMES
train_set = SideSe(data_set_yaml,
train_set = SideSet(data_set_yaml,
"train",
chunk_per_segment,
overlap,
training_df)
validation_set = SideSe(data_set_yaml,
validation_set = SideSet(data_set_yaml,
"validation",
chunk_per_segment,
overlap,
......
Supports Markdown
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