Commit 978bb202 authored by Alexander Fuchs's avatar Alexander Fuchs
Browse files

Workaround for multiprocess bug

parent c063d6b0
......@@ -143,7 +143,10 @@ class DataGenerator(object):
def create_feature(self,sample):
"""Creates the features by doing a STFT"""
filename = sample['filename']
if os.path.isfile(filename.replace("mp3","npz")) and not(self.force_feature_recalc):
return None
channels_str = sample['channels']
channels = int(channels_str.split(" ")[0])
if channels == 1:
......@@ -237,7 +240,7 @@ class DataGenerator(object):
pool = multiprocessing.Pool(os.cpu_count())
for i, _ in enumerate(pool.imap_unordered(self.create_feature, samples), 1):
sys.stderr.write('\rdone {0:%}'.format(i/n))
sys.stderr.write('\rdone {0:%}'.format(max(0,i/n)))
......@@ -258,6 +261,8 @@ class DataGenerator(object):
#Create features via STFT if no file exists
spectra = self.create_feature(sample)
sample['spectra'] = spectra
yield sample
if __name__ == "__main__":
......
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