Mercurial > hg > plosone_underreview
comparison scripts/load_features.py @ 46:3ed4c6af5a93 branch-tests
fixed indentation
author | Maria Panteli <m.x.panteli@gmail.com> |
---|---|
date | Fri, 15 Sep 2017 16:34:30 +0100 |
parents | 06e5711f9f62 |
children |
comparison
equal
deleted
inserted
replaced
45:ef829b187308 | 46:3ed4c6af5a93 |
---|---|
119 #min_dur_sec=8.0 | 119 #min_dur_sec=8.0 |
120 #min_n_frames = np.int(np.floor(min_dur_sec * self.framessr2)) | 120 #min_n_frames = np.int(np.floor(min_dur_sec * self.framessr2)) |
121 if len(music_idx)==0: # or len(music_idx)<min_n_frames: | 121 if len(music_idx)==0: # or len(music_idx)<min_n_frames: |
122 # no music segments or music segment too short -> skip this file | 122 # no music segments or music segment too short -> skip this file |
123 continue | 123 continue |
124 if 1: | 124 try: |
125 # allow feature extraction of longer segments (2*stop_sec) | 125 # allow feature extraction of longer segments (2*stop_sec) |
126 # because some of it might be speech segments that are filtered out | 126 # because some of it might be speech segments that are filtered out |
127 stop_sec_feat = 2 * stop_sec | 127 stop_sec_feat = 2 * stop_sec |
128 op, mfcc = self.get_op_mfcc_for_file(df['Melspec'].iloc[i], stop_sec=stop_sec_feat) | 128 op, mfcc = self.get_op_mfcc_for_file(df['Melspec'].iloc[i], stop_sec=stop_sec_feat) |
129 ch = self.get_chroma_for_file(df['Chroma'].iloc[i], stop_sec=stop_sec_feat) | 129 ch = self.get_chroma_for_file(df['Chroma'].iloc[i], stop_sec=stop_sec_feat) |
130 pb = self.get_pb_for_file(df['Melodia'].iloc[i], precomp_melody=precomp_melody, stop_sec=stop_sec_feat) | 130 pb = self.get_pb_for_file(df['Melodia'].iloc[i], precomp_melody=precomp_melody, stop_sec=stop_sec_feat) |
131 #if precomp_melody: | 131 #if precomp_melody: |
132 # pb = self.load_precomputed_pb_from_melodia(df['Melodia'].iloc[i], stop_sec=stop_sec) | 132 # pb = self.load_precomputed_pb_from_melodia(df['Melodia'].iloc[i], stop_sec=stop_sec) |
133 #else: | 133 #else: |
134 # pb = self.get_pb_from_melodia(df['Melodia'].iloc[i], stop_sec=stop_sec) | 134 # pb = self.get_pb_from_melodia(df['Melodia'].iloc[i], stop_sec=stop_sec) |
135 else: | 135 except: |
136 continue | 136 continue |
137 n_stop = np.int(np.ceil(stop_sec * self.framessr2)) | 137 n_stop = np.int(np.ceil(stop_sec * self.framessr2)) |
138 print n_stop, len(op), len(mfcc), len(ch), len(pb) | 138 print n_stop, len(op), len(mfcc), len(ch), len(pb) |
139 max_n_frames = np.min([n_stop, len(op), len(mfcc), len(ch), len(pb)]) # ideally, features should have the same number of frames | 139 max_n_frames = np.min([n_stop, len(op), len(mfcc), len(ch), len(pb)]) # ideally, features should have the same number of frames |
140 if max_n_frames==0: | 140 if max_n_frames==0: |
274 root_SM = '/import/c4dm-04/mariap/FeatureCsvs/PB-melodia/' | 274 root_SM = '/import/c4dm-04/mariap/FeatureCsvs/PB-melodia/' |
275 if 'SampleAudio' in base: | 275 if 'SampleAudio' in base: |
276 root = root_SM | 276 root = root_SM |
277 else: | 277 else: |
278 root = root_BL | 278 root = root_BL |
279 base = base.split('_')[-1].split('.csv')[0]+'_vamp_mtg-melodia_melodia_melody.csv' | 279 base = base.split('_')[-1].split('.csv')[0]+'_vamp_mtg-melodia_melodia_melody.csv' |
280 bihist_file = os.path.join(root, base) | 280 bihist_file = os.path.join(root, base) |
281 if not os.path.exists(bihist_file): | 281 if not os.path.exists(bihist_file): |
282 return pbihist | 282 return pbihist |
283 print 'load precomputed pitch bihist', root | 283 print 'load precomputed pitch bihist', root |
284 pbihist = np.loadtxt(bihist_file, delimiter=',').T | 284 pbihist = np.loadtxt(bihist_file, delimiter=',').T |