-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirm_use.py
More file actions
70 lines (66 loc) · 2.93 KB
/
confirm_use.py
File metadata and controls
70 lines (66 loc) · 2.93 KB
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
import numpy as np
def get_confirm_fftdata(list1, list2):
confirmList = []
list1 = list1
list2 = list2
for music1 in list1:
count = 0
for music2 in list2:
# 分為單/ 雙聲道, 已dict.Keys()
if len(music1["fftData"].keys()) == 1:
if len(music2["fftData"].keys()) == 1:
if (np.array_equal(music1["fftData"]["monoaural"], music2["fftData"]["monoaural"])):
temp = {
"Music1": music1["name"],
"Music2": music2["name"],
}
# 測試資料比對正確後, popout後續比對可以減少一次
testData = list2.pop(count)
# 比對完成的資料放置於confirmList
confirmList.append(temp)
break
count += 1
elif len(music2["fftData"].keys()) == 2:
count += 1
elif len(music1["fftData"].keys()) == 2:
if len(music2["fftData"].keys()) == 1:
count += 1
elif len(music2["fftData"].keys()) == 2:
if (
np.array_equal(music1["fftData"]["left_channel"], music2["fftData"]["left_channel"])) and (
np.array_equal(music1["fftData"]["right_channel"], music2["fftData"]["right_channel"])):
temp = {
"Music1": music1["name"],
"Music2": music2["name"],
}
# 測試資料比對正確後, popout後續比對可以減少一次
testData = list2.pop(count)
# 比對完成的資料放置於confirmList
confirmList.append(temp)
break
count += 1
else:
raise Exception("解析的音檔資料格式陣列要小於2")
return confirmList
def get_confirm_fragment(speclist, testlist):
confirmList = []
list1 = speclist
list2 = testlist
for music1 in list1:
count = 0
for music2 in list2:
if len(music1["fragment"].shape) == 1 and len(music2["fragment"].shape) == 1:
if np.array_equal(music1["fragment"], music2["fragment"]):
temp = {
"Music1": music1["name"],
"Music2": music2["name"],
}
# 測試資料比對正確後, popout後續比對可以減少一次
popout = list2.pop(count)
# 比對完成的資料放置於confirmList
confirmList.append(temp)
break
count += 1
else:
raise Exception("解析的音檔資料格式陣列要小於等於1")
return confirmList