mirror of
https://github.com/correl/dejavu.git
synced 2024-11-23 19:19:53 +00:00
fixes #15, adds handling for KeyboardInterrupt. added some handling for #4, now skips file not sampled at 44100hz
This commit is contained in:
parent
907637a633
commit
880af4a5b9
2 changed files with 17 additions and 7 deletions
|
@ -58,8 +58,14 @@ class Dejavu():
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
|
|
||||||
# wait for all processes to complete
|
# wait for all processes to complete
|
||||||
for p in processes:
|
try:
|
||||||
p.join()
|
for p in processes:
|
||||||
|
p.join()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print "-> Exiting.."
|
||||||
|
for worker in processes:
|
||||||
|
worker.terminate()
|
||||||
|
worker.join()
|
||||||
|
|
||||||
# delete orphans
|
# delete orphans
|
||||||
# print "Done fingerprinting. Deleting orphaned fingerprints..."
|
# print "Done fingerprinting. Deleting orphaned fingerprints..."
|
||||||
|
@ -77,11 +83,16 @@ class Dejavu():
|
||||||
# convert to WAV
|
# convert to WAV
|
||||||
wavout_path = self.converter.convert(filename, extension, Converter.WAV, output)
|
wavout_path = self.converter.convert(filename, extension, Converter.WAV, output)
|
||||||
|
|
||||||
|
# for each channel perform FFT analysis and fingerprinting
|
||||||
|
try:
|
||||||
|
channels = self.extract_channels(wavout_path)
|
||||||
|
except AssertionError, e:
|
||||||
|
print "-> File not supported, skipping."
|
||||||
|
continue
|
||||||
|
|
||||||
# insert song name into database
|
# insert song name into database
|
||||||
song_id = sql_connection.insert_song(filename)
|
song_id = sql_connection.insert_song(filename)
|
||||||
|
|
||||||
# for each channel perform FFT analysis and fingerprinting
|
|
||||||
channels = self.extract_channels(wavout_path)
|
|
||||||
for c in range(len(channels)):
|
for c in range(len(channels)):
|
||||||
channel = channels[c]
|
channel = channels[c]
|
||||||
print "-> Fingerprinting channel %d of song %s..." % (c+1, filename)
|
print "-> Fingerprinting channel %d of song %s..." % (c+1, filename)
|
||||||
|
@ -89,7 +100,6 @@ class Dejavu():
|
||||||
|
|
||||||
# remove wav file if not required
|
# remove wav file if not required
|
||||||
if not keep_wav:
|
if not keep_wav:
|
||||||
print "removing ", wavout_path
|
|
||||||
os.unlink(wavout_path)
|
os.unlink(wavout_path)
|
||||||
|
|
||||||
# only after done fingerprinting do confirm
|
# only after done fingerprinting do confirm
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Converter():
|
||||||
filepaths = []
|
filepaths = []
|
||||||
extensions = [e.replace(".", "") for e in extensions if e.replace(".", "") in Converter.FORMATS]
|
extensions = [e.replace(".", "") for e in extensions if e.replace(".", "") in Converter.FORMATS]
|
||||||
print "Supported formats: %s" % extensions
|
print "Supported formats: %s" % extensions
|
||||||
for dirpath, dirnames, files in os.walk(path) :
|
for dirpath, dirnames, files in os.walk(path):
|
||||||
for extension in extensions:
|
for extension in extensions:
|
||||||
for f in fnmatch.filter(files, "*.%s" % extension):
|
for f in fnmatch.filter(files, "*.%s" % extension):
|
||||||
p = os.path.join(dirpath, f)
|
p = os.path.join(dirpath, f)
|
||||||
|
@ -46,7 +46,7 @@ class Converter():
|
||||||
else:
|
else:
|
||||||
mp3file = AudioSegment.from_mp3(orig_path)
|
mp3file = AudioSegment.from_mp3(orig_path)
|
||||||
if self.max_input_len:
|
if self.max_input_len:
|
||||||
print "Reading input seconds: ", self.max_input_len
|
print "-> Reading input seconds: ", self.max_input_len
|
||||||
mp3file = mp3file[:self.max_input_len * 1000]
|
mp3file = mp3file[:self.max_input_len * 1000]
|
||||||
mp3file.export(newpath, format=Converter.WAV)
|
mp3file.export(newpath, format=Converter.WAV)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue