revamped testing script

This commit is contained in:
Will Drevo 2014-07-02 23:49:38 -04:00
parent b966225ad4
commit 7cbb894501
2 changed files with 13 additions and 9 deletions

View file

@ -4,8 +4,14 @@ import fingerprint
import multiprocessing import multiprocessing
import os import os
class Dejavu(object): class Dejavu(object):
SONG_ID = "song_id"
SONG_NAME = 'song_name'
CONFIDENCE = 'confidence'
MATCH_TIME = 'match_time'
OFFSET = 'offset'
def __init__(self, config): def __init__(self, config):
super(Dejavu, self).__init__() super(Dejavu, self).__init__()
@ -136,18 +142,17 @@ class Dejavu(object):
# extract idenfication # extract idenfication
song = self.db.get_song_by_id(song_id) song = self.db.get_song_by_id(song_id)
if song: if song:
# TODO: Clarifey what `get_song_by_id` should return. # TODO: Clarify what `get_song_by_id` should return.
songname = song.get("song_name", None) songname = song.get(Dejavu.SONG_NAME, None)
else: else:
return None return None
# return match info # return match info
song = { song = {
"song_id": song_id, Dejavu.SONG_ID : song_id,
"song_name": songname, Dejavu.SONG_NAME : songname,
"confidence": largest_count, Dejavu.CONFIDENCE : largest_count,
"offset": largest Dejavu.OFFSET : largest }
}
return song return song

View file

@ -9,7 +9,6 @@ from os import listdir
from os.path import isfile, join from os.path import isfile, join
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.animation as animation
from optparse import OptionParser from optparse import OptionParser
from dejavu.decoder import path_to_songname from dejavu.decoder import path_to_songname
import ast import ast