コード例 #1
0
ファイル: comparison.py プロジェクト: rhythmsection/MHBv3
def compare_fingerprint_to_database(filename):

	'''
	Takes the mono .wav file and creates a fingerprint of it, which it then compares 
	to the existing database of fingerprints, returning information of most likely match.

	'''

	user_audio = fingerprint.location_fingerprint(filename)
	fingerprints = model.Fingerprint.query.all()
	database_iteration = []
	max_offset = 0
	for row in fingerprints:
		db_audio = cPickle.loads(row.fingerprint)
		ranked_matches = align(user_audio, db_audio)
		current_song = {}
		song_match = {}

		current_song["title"] = row.title
		current_song["artist"] = row.artist
		current_song["offset"] = ranked_matches[0][1]
		current_song["high_match"] = False
		database_iteration.append(current_song)

	for current_song in database_iteration:
		if current_song["offset"] > max_offset:
			max_offset = current_song["offset"]

	for current_song in database_iteration:
		if current_song["offset"] == max_offset:
			current_song["high_match"] = True

	return database_iteration
コード例 #2
0
ファイル: comparison.py プロジェクト: rhythmsection/MHB
def compare_fingerprint_to_database(filename):
	file1 = fingerprint.location_fingerprint(filename)
	fingerprints = session.query(model.Fingerprint)
	database_iteration = []
	max_offset = 0
	for row in fingerprints:
		file2 = pickle.loads(row.fingerprint)
		ranked_matches = align.align(file1, file2)
		current_song = {}
		song_match = {}

#assorted song information
		current_song["title"] = row.title
		current_song["artist"] = row.artist
		current_song["album"] = row.album
		current_song["offset"] = ranked_matches[0][1]
		database_iteration.append(current_song)

	for current_song in database_iteration:
		if current_song["offset"] > max_offset:
			max_offset = current_song["offset"]

#information for most likely match
	for current_song in database_iteration:
		if current_song["offset"] == max_offset:
			song_match["title"] = current_song["title"]
			song_match["artist"] = current_song["artist"]
			song_match["album"] = current_song["album"]

	return song_match
コード例 #3
0
ファイル: base_app.py プロジェクト: rhythmsection/MHBv3
def add_fingerprint():

	'''Add individual music data (including fingerprint) to database.'''

	title = request.form.get('title')
	artist = request.form.get('artist')
	music_file = request.files['music_file']
	filename = secure_filename("user_input.wav")
	music_file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
	comparison.change_stereo_to_mono(filename)
	time.sleep(1)
	music_fingerprint = fingerprint.location_fingerprint(filename)
	pickled_song_fingerprint = cPickle.dumps(music_fingerprint)
	new_fingerprint = Fingerprint(title = title,
								  artist = artist,
								  fingerprint = pickled_song_fingerprint)

	db.session.add(new_fingerprint)
	db.session.commit()

	return redirect("/database")
コード例 #4
0
ファイル: seed.py プロジェクト: rhythmsection/MHB
def load_test_data(wav_file):
	song_fingerprint = fingerprint.location_fingerprint(wav_file)
	pickled_song_fingerprint = pickle.dumps(song_fingerprint)
	song = model.Fingerprint(fingerprint = pickled_song_fingerprint)
	session.add(song)
	session.commit()