From 0b36781ccdd017379b236bf5b15c01953a213f7b Mon Sep 17 00:00:00 2001 From: Pedro Guridi Date: Tue, 17 Dec 2013 19:42:39 -0300 Subject: [PATCH] fixes #4, now wav files storage is optional --- dejavu/control.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dejavu/control.py b/dejavu/control.py index 606e366..2fdac40 100644 --- a/dejavu/control.py +++ b/dejavu/control.py @@ -34,7 +34,7 @@ class Dejavu(): """ return [lst[i::n] for i in xrange(n)] - def fingerprint(self, path, output, extensions, nprocesses): + def fingerprint(self, path, output, extensions, nprocesses, keep_wav=False): # convert files, shuffle order files = self.converter.find_files(path, extensions) @@ -53,7 +53,7 @@ class Dejavu(): self.config.get(SQLDatabase.CONNECTION, SQLDatabase.KEY_DATABASE)) # create process and start it - p = Process(target=self.fingerprint_worker, args=(files_split[i], sql_connection, output)) + p = Process(target=self.fingerprint_worker, args=(files_split[i], sql_connection, output, keep_wav)) p.start() processes.append(p) @@ -66,7 +66,7 @@ class Dejavu(): # TODO: need a more performant query in database.py for the #self.fingerprinter.db.delete_orphans() - def fingerprint_worker(self, files, sql_connection, output): + def fingerprint_worker(self, files, sql_connection, output, keep_wav): for filename, extension in files: @@ -89,6 +89,11 @@ class Dejavu(): print "-> Fingerprinting channel %d of song %s..." % (c+1, song_name) self.fingerprinter.fingerprint(channel, wavout_path, song_id, c+1) + # remove wav file if not required + if not keep_wav: + print "removing ", wavout_path + os.unlink(wavout_path) + # only after done fingerprinting do confirm sql_connection.set_song_fingerprinted(song_id) @@ -104,4 +109,4 @@ class Dejavu(): for channel in range(nchannels): channels.append(frames[:, channel]) - return channels \ No newline at end of file + return channels