Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions collect-fingerprints-of-songs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@
colored('channels=%d', 'white', attrs=['dark']), # channels
colored('%s', 'white', attrs=['bold']) # filename
)
print msg % (song_id, len(audio['channels']), filename)
print (msg % (song_id, len(audio['channels']), filename))

if song:
hash_count = db.get_song_hashes_count(song_id)

if hash_count > 0:
msg = ' already exists (%d hashes), skip' % hash_count
print colored(msg, 'red')
print (colored(msg, 'red'))

continue

print colored(' new song, going to analyze..', 'green')
print (colored(' new song, going to analyze..', 'green'))

hashes = set()
channel_amount = len(audio['channels'])

for channeln, channel in enumerate(audio['channels']):
msg = ' fingerprinting channel %d/%d'
print colored(msg, attrs=['dark']) % (channeln+1, channel_amount)
print (colored(msg, attrs=['dark']) % (channeln+1, channel_amount))

channel_hashes = fingerprint.fingerprint(channel, Fs=audio['Fs'], plots=config['fingerprint.show_plots'])
channel_hashes = set(channel_hashes)

msg = ' finished channel %d/%d, got %d hashes'
print colored(msg, attrs=['dark']) % (
print (colored(msg, attrs=['dark']) % (
channeln+1, channel_amount, len(channel_hashes)
)
))

hashes |= channel_hashes

Expand All @@ -67,7 +67,7 @@
values.append((song_id, hash, offset))

msg = ' storing %d hashes in db' % len(values)
print colored(msg, 'green')
print (colored(msg, 'green'))

db.store_fingerprints(values)

Expand Down
4 changes: 1 addition & 3 deletions config-development.sample.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"env": "development",

// you can use any of cloud-based or local mongo servers
// like https://mlab.com/

"db.dsn": "mongodb://user:password@cloud-domain:port/",
"db.database": "database-name-here"
}
18 changes: 9 additions & 9 deletions get-database-stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def printSummary():
colored('%d song(s)', 'yellow'), # songs
colored('%d fingerprint(s)', 'yellow') # fingerprints
)
print msg % row
print (msg % row)

return row[0] # total

Expand All @@ -36,7 +36,7 @@ def printSongs():
colored('%s', 'white', attrs=['bold']), # name
colored('%d hashes', 'green') # hashes
)
print msg % row
print (msg % row)

# find duplicates
def printDuplicates():
Expand All @@ -54,15 +54,15 @@ def printDuplicates():
""")

msg = ' * duplications: %s' % colored('%d song(s)', 'yellow')
print msg % len(rows)
print (msg % len(rows))

for row in rows:
msg = ' ** %s %s: %s' % (
colored('id=%s','white',attrs=['dark']),
colored('%s', 'white', attrs=['bold']),
colored('%d duplicate(s)', 'red')
)
print msg % row
print (msg % row)

# find colissions
def printColissions():
Expand All @@ -82,19 +82,19 @@ def printColissions():
if rows[0][0] is not None:
val = rows[0]

print msg % val
print (msg % val)

if __name__ == '__main__':
db = SqliteDatabase()
print ''
print ('')

x = printSummary()
printSongs()
if x: print ''
if x: print ('')

printDuplicates()
if x: print ''
if x: print ('')

printColissions()

print '\ndone'
print ('\ndone')
2 changes: 1 addition & 1 deletion libs/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def fingerprint(channel_samples, Fs=DEFAULT_FS,
local_maxima = get_2D_peaks(arr2D, plot=plots, amp_min=amp_min)

msg = ' local_maxima: %d of frequency & time pairs'
print colored(msg, attrs=['dark']) % len(local_maxima)
print (colored(msg, attrs=['dark']) % len(local_maxima))

# return hashes
return generate_hashes(local_maxima, fan_value=fan_value)
Expand Down
10 changes: 5 additions & 5 deletions reset-database.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# songs table

db.query("DROP TABLE IF EXISTS songs;")
print('removed db.songs');
print('removed db.songs')

db.query("""
CREATE TABLE songs (
Expand All @@ -17,13 +17,13 @@
filehash TEXT
);
""")
print('created db.songs');
print('created db.songs')

#
# fingerprints table

db.query("DROP TABLE IF EXISTS fingerprints;")
print('removed db.fingerprints');
print('removed db.fingerprints')

db.query("""
CREATE TABLE `fingerprints` (
Expand All @@ -33,6 +33,6 @@
`offset` INTEGER
);
""")
print('created db.fingerprints');
print('created db.fingerprints')

print('done');
print('done')