-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
146 lines (128 loc) · 4.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
from Audio_Fingerprinting import *
import Fingerprint_alignment as fa
from mysqlDB import *
from scipy.io import wavfile
#LOGGING CONFIG
logging.basicConfig(filename='log_basedatos.log', encoding='utf-8', level=logging.DEBUG)
#MAIN
#user input
#archivo = 'Lavender_Town_Japan.wav'
#samplerate,data = wavfile.read(archivo)
# nombre = input("Ingresa el nombre de la cancion: ")
#interprete = input("Ingresa el nombre del autor: ")
#insert song into database
#hashes = fingerprint(data)
#id = insert_song(nombre, interprete)
#print(id)
#if id is not None:
#insert_hashes(id, hashes)
#insert song into database
def songs_toDB():
#insert gorillaz song
file='input_songs/Baby Queen slowed.wav'
samplerate,data = wavfile.read(file)
nombre = "Baby Queen"
interprete = "Gorillaz"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert Skrillex song
file='input_songs/Bangarang.wav'
samplerate,data = wavfile.read(file)
nombre = "Bangarang"
interprete = "Skrillex"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert Despacito song
file='input_songs/Despacito.wav'
samplerate,data = wavfile.read(file)
nombre = "Despacito"
interprete = "Luis Fonsi"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert Disc 13 song
file='input_songs/Disc 13.wav'
samplerate,data = wavfile.read(file)
nombre = "Disc 13"
interprete = "C418"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert disc 11 song
file='input_songs/Disc 11.wav'
samplerate,data = wavfile.read(file)
nombre = "Disc 11"
interprete = "C418"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert Clams Casino song
file = "input_songs/I'm God.wav"
samplerate,data = wavfile.read(file)
nombre = "Im God"
interprete = "Clams Casino"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert Monster song
file = "input_songs/Monster.wav"
samplerate,data = wavfile.read(file)
nombre = "Monster"
interprete = "Meg & Dia"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
# insert Martin Garrix song
file = "input_songs/These Are The Times.wav"
samplerate,data = wavfile.read(file)
nombre = "These Are The Times"
interprete = "Martin Garrix"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#insert virtual self Ghost Voices song
file = "input_songs/Ghost Voices.wav"
samplerate,data = wavfile.read(file)
nombre = "Ghost Voices"
interprete = "Virtual Self"
hashes = fingerprint(data)
id = insert_song(nombre, interprete)
print(id)
if id is not None:
insert_hashes(id, hashes)
#songs_toDB()
#input recording to compare
file = "Grabación.wav"
samplerate,data = wavfile.read(file)
#fingerprinting input recording unpacking
hashes , process_time = fa.genFingerprints(data, samplerate)
print("Fingerprinting time: ", process_time, " seconds")
#compare fingerprints with database
matches, query_matches, processing_Time = fa.findMatches(hashes)
print("Processing comparing time: ", processing_Time, " seconds")
#align matches
match_results = fa.align_matches(matches, query_matches,2)
#display results
#print("Results:", match_results)
print("Results:")
for result in match_results:
print("Song: ", result.get("song_name"), " by ", result.get("song_author"), " with ", result.get("hashes_matched"), " matches")
#algorithm to align matches