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

cleaning

parent feb27cb1
......@@ -603,16 +603,10 @@ class IdMapSet(Dataset):
stop = int(self.idmap.stop[index])
# add this in case the segment is too short
if stop - start <= self.min_duration * nfo.samplerate:
print("Segment trop court")
print(f"Get: {stop - start} and need {self.min_duration * nfo.samplerate}")
print(f"self.min_duration = {self.min_duration}, nfo.samplerate = {nfo.samplerate}")
print(f"start = {start}, stop = {stop}\t start//160 {start//160}, stop {stop//160}")
middle = start + (stop - start) // 2
print(f"middle = {middle}")
start = max(0, int(middle - (self.min_duration * nfo.samplerate / 2)))
stop = int(start + self.min_duration * nfo.samplerate)
print(f"Apres modification: start = {start}, stop = {stop} total duration: {stop - start}")
sig, _ = soundfile.read(f"{self.data_root_path}/{self.idmap.rightids[index]}.{self.file_extension}",
start=start,
stop=stop)
......@@ -621,7 +615,6 @@ class IdMapSet(Dataset):
if self.transform_pipeline is not None:
sig, _, ___, _____, _t, _s = self.transforms((sig, 0, 0, 0, 0, 0))
return torch.from_numpy(sig).type(torch.FloatTensor), \
self.idmap.leftids[index], \
self.idmap.rightids[index], \
......
......@@ -956,7 +956,7 @@ def extract_embeddings(idmap_name,
file_extension=file_extension,
transform_pipeline=transform_pipeline,
frame_rate=int(1. / frame_shift),
min_duration=(model.context_size() + 2) * frame_shift
min_duration=(model.context_size() + 2) * frame_shift * 2
)
dataloader = DataLoader(dataset,
......
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