From da4dd3e1616c8eeef86aa8662d932bc53e4d96e5 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Wed, 2 Sep 2020 16:58:59 -0400 Subject: [PATCH] Use recent, not oldest, audio for fingerprinting --- turntable/turntable.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/turntable/turntable.py b/turntable/turntable.py index a6cf243..054e03e 100644 --- a/turntable/turntable.py +++ b/turntable/turntable.py @@ -122,13 +122,8 @@ class Turntable(Process): >= FINGERPRINT_DELAY + FINGERPRINT_IDENTIFY_SECONDS and self.identified == False ): - startframe = self.buffer.framerate * ( - FINGERPRINT_DELAY + FINGERPRINT_IDENTIFY_DELAY - ) - endframe = ( - startframe + self.buffer.framerate * FINGERPRINT_IDENTIFY_SECONDS - ) - sample = self.buffer[startframe:endframe] + startframe = - self.buffer.framerate * FINGERPRINT_IDENTIFY_SECONDS + sample = self.buffer[startframe:] identification = self.recognizer.recognize(sample) logger.debug("Dejavu results: %s", identification) if results := identification[dejavu.config.settings.RESULTS]: @@ -142,11 +137,8 @@ class Turntable(Process): now - self.last_update >= FINGERPRINT_DELAY + FINGERPRINT_STORE_SECONDS and self.captured == False ): - startframe = self.buffer.framerate * FINGERPRINT_DELAY - endframe = ( - startframe + self.buffer.framerate * FINGERPRINT_STORE_SECONDS - ) - sample = self.buffer[startframe:endframe] + startframe = - self.buffer.framerate * FINGERPRINT_STORE_SECONDS + sample = self.buffer[startframe:] with wave.open("/tmp/fingerprint.wav", "wb") as wavfile: wavfile.setsampwidth(2) wavfile.setnchannels(sample.channels)