コード例 #1
0
    for i in range(frame_number):
        s = wavdata.readframes(frame_size)
        s = np.frombuffer(s, dtype='<i2') 
        y = mp.sparse(s)
        keys = mp.extractKeys(y)
        query.extend([(Binary(hash_key)[0:5],track_id, int(i*frame_size+offset)) for (hash_key,offset) in keys])


        if i*100/frame_number >= progress + 10:
            progress = i * 100/frame_number
        #print("%d%%," % (progress,)),
    

    database = Database()
    database.addFingerprint(query)
    del database

    print("100%")











コード例 #2
0
total_keys = 0

for track in music_list:
    track_title = track[:-4]
    track_id = database.addTrack(track_title)
    print("=> Processing %s, id: %d" % (track_title, track_id))
    wavdata = sound.read(music_dir + "/" + track)

    total_duree += wavdata.getnframes() / float(wavdata.getframerate())

    # Shazam method
    keys = shazam.processTrack(wavdata, )

    total_keys += len(keys)
    print total_keys / total_duree

    print("=> %d keys" % len(keys))

    query = []
    for key in keys:
        string = str(key[0]) + '-' + str(key[1]) + '-' + str(key[2])
        offset = int(key[3])
        key_hash = hashlib.sha1(string).digest()
        key_hash = key_hash[0:5]
        key_hash = sqlite3.Binary(key_hash)
        query.append((key_hash, track_id, offset))

    database.addFingerprint(query, 'shazam')

    # Matching pursuit method
コード例 #3
0
	track_title = track[:-4]
	track_id = database.addTrack(track_title)
	print("=> Processing %s, id: %d" % (track_title, track_id))
	wavdata = sound.read(music_dir + "/" + track)

	total_duree += wavdata.getnframes()/float(wavdata.getframerate())

	# Shazam method
	keys = shazam.processTrack(wavdata,)

	total_keys += len(keys)
	print total_keys/total_duree

	print("=> %d keys" % len(keys))

	query = []
	for key in keys:
		string = str(key[0]) + '-' + str(key[1]) + '-' + str(key[2])
		offset = int(key[3])
		key_hash = hashlib.sha1(string).digest()
		key_hash = key_hash[0:5]
		key_hash = sqlite3.Binary(key_hash)
		query.append((key_hash, track_id, offset))

	database.addFingerprint(query, 'shazam')

	# Matching pursuit method



コード例 #4
0
    track_id = database.addTrack(track_title)
    del database
    print("=> Processing %s, id: %d" % (track_title, track_id))

    wavdata = sound.read(track)
    Fe = wavdata.getframerate()
    frame_number = int(wavdata.getnframes() / frame_size)

    print("%d frames to process for this track" % frame_number)

    progress = 0

    for i in range(frame_number):
        s = wavdata.readframes(frame_size)
        s = np.frombuffer(s, dtype='<i2')
        y = mp.sparse(s)
        keys = mp.extractKeys(y)
        query.extend([(Binary(hash_key)[0:5], track_id,
                       int(i * frame_size + offset))
                      for (hash_key, offset) in keys])

        if i * 100 / frame_number >= progress + 10:
            progress = i * 100 / frame_number
        #print("%d%%," % (progress,)),

    database = Database()
    database.addFingerprint(query)
    del database

    print("100%")