Exemple #1
0
def music_recognition():
	file = request.files['user_audio']
	filename = secure_filename("user_input.wav")
	file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
	comparison.change_stereo_to_mono(filename)
	time.sleep(1)
	database_iteration = comparison.compare_fingerprint_to_database("new_user_input.wav")
	return json.dumps(database_iteration)
Exemple #2
0
def run_algorithm():

	'''AJAX call takes in the file from getUserMedia, names it "user_input.wav", 
	uploads it and then runs compare_fingerprint_to_database on it, returning 
	the results as a JSON object.'''

	music_file = request.files['music_clip']
	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)
	database_iteration = comparison.compare_fingerprint_to_database("new_user_input.wav")

	for song in database_iteration:
		if song["high_match"] == True:
			session['match'] = {'title': song['title'], 'artist': song['artist'], 'offset': song['offset']}
	return json.dumps(database_iteration)