From 7895bae23eefd4dbe19e6be20a4f8e1f403c337d Mon Sep 17 00:00:00 2001 From: Wessie Date: Wed, 18 Dec 2013 18:15:57 +0100 Subject: [PATCH] Fixed any references to old converter to use the new functions. - Reversed return values in decode.read --- dejavu/__init__.py | 11 +++-------- dejavu/decode.py | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/dejavu/__init__.py b/dejavu/__init__.py index 3222395..f9be8bd 100755 --- a/dejavu/__init__.py +++ b/dejavu/__init__.py @@ -1,5 +1,5 @@ from dejavu.database import SQLDatabase -from dejavu.convert import Converter +import dejavu.decode as decoder import fingerprint from scipy.io import wavfile from multiprocessing import Process @@ -16,8 +16,6 @@ class Dejavu(object): # initialize db self.db = SQLDatabase(**config.get("database", {})) - # create components - self.converter = Converter() #self.fingerprinter = Fingerprinter(self.config) self.db.setup() @@ -41,7 +39,7 @@ class Dejavu(object): def do_fingerprint(self, path, output, extensions, nprocesses): # convert files, shuffle order - files = self.converter.find_files(path, extensions) + files = decoder.find_files(path, extensions) random.shuffle(files) files_split = self.chunkify(files, nprocesses) @@ -74,14 +72,11 @@ class Dejavu(object): print("-> Already fingerprinted, continuing...") continue - # convert to WAV - wavout_path = self.converter.convert(filename, extension, Converter.WAV, output, song_name) + channels, Fs = decoder.read(filename) # insert song name into database song_id = sql_connection.insert_song(song_name) - # for each channel perform FFT analysis and fingerprinting - channels, Fs = self.extract_channels(wavout_path) for c in range(len(channels)): channel = channels[c] print "-> Fingerprinting channel %d of song %s..." % (c+1, song_name) diff --git a/dejavu/decode.py b/dejavu/decode.py index f578c0e..47193ca 100644 --- a/dejavu/decode.py +++ b/dejavu/decode.py @@ -24,7 +24,7 @@ def read(filename, limit=None): of the file by specifying the `limit` parameter. This is the amount of seconds from the start of the file. - returns: (samplerate, channels) + returns: (channels, samplerate) """ audiofile = AudioSegment.from_file(filename) @@ -37,4 +37,4 @@ def read(filename, limit=None): for chn in xrange(audiofile.channels): channels.append(data[chn::audiofile.channels]) - return audiofile.frame_rate, channels + return channels, audiofile.frame_rate