mirror of
https://github.com/correl/turntable.git
synced 2024-11-23 19:19:55 +00:00
Use recent, not oldest, audio for fingerprinting
This commit is contained in:
parent
10b0aded20
commit
da4dd3e161
1 changed files with 4 additions and 12 deletions
|
@ -122,13 +122,8 @@ class Turntable(Process):
|
||||||
>= FINGERPRINT_DELAY + FINGERPRINT_IDENTIFY_SECONDS
|
>= FINGERPRINT_DELAY + FINGERPRINT_IDENTIFY_SECONDS
|
||||||
and self.identified == False
|
and self.identified == False
|
||||||
):
|
):
|
||||||
startframe = self.buffer.framerate * (
|
startframe = - self.buffer.framerate * FINGERPRINT_IDENTIFY_SECONDS
|
||||||
FINGERPRINT_DELAY + FINGERPRINT_IDENTIFY_DELAY
|
sample = self.buffer[startframe:]
|
||||||
)
|
|
||||||
endframe = (
|
|
||||||
startframe + self.buffer.framerate * FINGERPRINT_IDENTIFY_SECONDS
|
|
||||||
)
|
|
||||||
sample = self.buffer[startframe:endframe]
|
|
||||||
identification = self.recognizer.recognize(sample)
|
identification = self.recognizer.recognize(sample)
|
||||||
logger.debug("Dejavu results: %s", identification)
|
logger.debug("Dejavu results: %s", identification)
|
||||||
if results := identification[dejavu.config.settings.RESULTS]:
|
if results := identification[dejavu.config.settings.RESULTS]:
|
||||||
|
@ -142,11 +137,8 @@ class Turntable(Process):
|
||||||
now - self.last_update >= FINGERPRINT_DELAY + FINGERPRINT_STORE_SECONDS
|
now - self.last_update >= FINGERPRINT_DELAY + FINGERPRINT_STORE_SECONDS
|
||||||
and self.captured == False
|
and self.captured == False
|
||||||
):
|
):
|
||||||
startframe = self.buffer.framerate * FINGERPRINT_DELAY
|
startframe = - self.buffer.framerate * FINGERPRINT_STORE_SECONDS
|
||||||
endframe = (
|
sample = self.buffer[startframe:]
|
||||||
startframe + self.buffer.framerate * FINGERPRINT_STORE_SECONDS
|
|
||||||
)
|
|
||||||
sample = self.buffer[startframe:endframe]
|
|
||||||
with wave.open("/tmp/fingerprint.wav", "wb") as wavfile:
|
with wave.open("/tmp/fingerprint.wav", "wb") as wavfile:
|
||||||
wavfile.setsampwidth(2)
|
wavfile.setsampwidth(2)
|
||||||
wavfile.setnchannels(sample.channels)
|
wavfile.setnchannels(sample.channels)
|
||||||
|
|
Loading…
Reference in a new issue