-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (38 loc) · 1.09 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
#!/usr/bin/env python3
from processor import normalize, dtw, euc
from pextraction import track_pitch
from visualizer import timeseries
from recorder import Recorder
import database
def process(hum):
hum_normalized = normalize(hum)
data = database.load()
l = {}
for alias in data:
original = data[alias]['pitches']
normalized = normalize(original)
dtwdist, dtwpath = dtw(hum_normalized, normalized, euc, 14)
l[alias] = (dtwdist, dtwpath)
for alias in l:
print(alias, l[alias][0])
def main():
# start recording -> 5 sec default
recorder = Recorder()
frames = recorder.start(5)
recorder.write_wav(frames, "input.wav")
# load the hum and process
hum = track_pitch("input.wav")
timeseries(hum)
process(hum)
"""
print("hum vs original")
x = normalize(x)
dtwdist, dtwpath = dtw(x, z, euc, 14)
print(dtwdist)
y = normalize(track_pitch("notNearOriginal.wav"))
print("hum vs non-original")
dtwdist, dtwpath = dtw(x, y, euc, 14)
print(dtwdist)
"""
if __name__ == "__main__":
main()