Commit e6736976 authored by Hubert Nourtel's avatar Hubert Nourtel
Browse files

Allow negative values for duration to select max duration for audio

parent 5c97ff5e
......@@ -225,9 +225,9 @@ class SideSet(Dataset):
assert isinstance(dataset_df, pandas.DataFrame)
df = dataset_df
if self.duration == -1:
# Duration is set to -1, select the whole audio
self.sessions = df
if self.duration < 0:
# Duration is set to negative, select the whole audio from utterances with duration <= |self.duration|
self.sessions = df.loc[df['duration'] <= abs(self.duration)]
self.len = len(self.sessions)
self.initial_len = len(self.sessions)
else:
......@@ -330,7 +330,7 @@ class SideSet(Dataset):
nfo = torchaudio.info(f"{self.data_path}/{current_session['file_id']}{self.data_file_extension}")
conversion_rate = nfo.sample_rate // self.sample_rate
if self.duration == -1:
if self.duration < 0:
frame_offset = 0
sample_number = int((nfo.num_frames/nfo.sample_rate) * self.sample_rate)
else:
......
......@@ -635,7 +635,7 @@ def get_loaders(dataset_opts, training_opts, model_opts, local_rank=0):
num_process=1,
num_replicas=dataset_opts["train"]["sampler"]["augmentation_replica"]
)
if dataset_opts["train"]["duration"] == -1:
if dataset_opts["train"]["duration"] < 0:
# Use custom collate
collate_hook_file = model_opts["collate_hook"]
if not os.path.isfile(collate_hook_file):
......
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