comparison scripts/load_features.py @ 34:115774aff442 branch-tests

music bounds not centered but aligned with start of segment to match the way features are computed
author Maria Panteli
date Thu, 14 Sep 2017 10:16:59 +0100
parents e4736064d282
children c4428589b82b
comparison
equal deleted inserted replaced
33:928d9bf9224f 34:115774aff442
74 return music_idx 74 return music_idx
75 elif len(np.where(bounds[:,2]=='s')[0])==nbounds: 75 elif len(np.where(bounds[:,2]=='s')[0])==nbounds:
76 # all segments are speech 76 # all segments are speech
77 return music_idx 77 return music_idx
78 else: 78 else:
79 half_win_hop = int(round(0.5 * self.win2 / float(self.hop2))) 79 win2_frames = np.int(np.round(self.win2sec * self.framessr2))
80 #half_win_hop = int(round(0.5 * self.win2 / float(self.hop2)))
80 music_bounds = np.where(bounds[:, 2] == 'm')[0] 81 music_bounds = np.where(bounds[:, 2] == 'm')[0]
81 bounds_in_frames = np.round(np.array(bounds[:, 0], dtype=float) * sr) 82 bounds_in_frames = np.round(np.array(bounds[:, 0], dtype=float) * sr)
82 duration_in_frames = np.round(np.array(bounds[:, 1], dtype=float) * sr) 83 duration_in_frames = np.ceil(np.array(bounds[:, 1], dtype=float) * sr)
83 for music_bound in music_bounds: 84 for music_bound in music_bounds:
84 lower_bound = np.max([0, bounds_in_frames[music_bound] - half_win_hop]) 85 #lower_bound = np.max([0, bounds_in_frames[music_bound] - half_win_hop])
85 upper_bound = bounds_in_frames[music_bound] + duration_in_frames[music_bound] - half_win_hop 86 #upper_bound = bounds_in_frames[music_bound] + duration_in_frames[music_bound] - half_win_hop
87 lower_bound = bounds_in_frames[music_bound]
88 upper_bound = bounds_in_frames[music_bound] + duration_in_frames[music_bound] - win2_frames
86 music_idx.append(np.arange(lower_bound, upper_bound, dtype=int)) 89 music_idx.append(np.arange(lower_bound, upper_bound, dtype=int))
87 if len(music_idx)>0: 90 if len(music_idx)>0:
88 music_idx = np.sort(np.concatenate(music_idx)) # it should be sorted, but just in case segments overlap -- remove duplicates if segments overlap 91 music_idx = np.sort(np.concatenate(music_idx)) # it should be sorted, but just in case segments overlap -- remove duplicates if segments overlap
89 return music_idx 92 return music_idx
90 93