-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade_note_bitch_2019-04-17.py
75 lines (59 loc) · 2.27 KB
/
grade_note_bitch_2019-04-17.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
import matplotlib.pyplot as plt
import re
import shutil
import librosa.display
import matplotlib.pyplot as plt
from create_base import *
from create_labels_files import *
from find_mismatch import *
from grade import *
from note_line import *
score = 0
date = '3.19'
src_path = 'F:/项目/花城音乐项目/样式数据/3.19MP3/节奏/'
new_old_txt = './onsets/'+date+'best_dtw.txt'
# 保存新文件名与原始文件的对应关系
files_list = []
files_list_a = []
files_list_b = []
files_list_c = []
files_list_d = []
# new_old_txt = './onsets/best_dtw.txt'
files = list_all_files(src_path)
print(files)
index = 0
# 用于分析人工打分与算法打分误差
# 测试单个文件
#files = ['F:/项目/花城音乐项目/样式数据/2.27MP3/节奏/节奏六(5)(80).wav']
#files = ['F:/项目/花城音乐项目/样式数据/2.27MP3/节奏/节奏8_40210(30).wav']
for filename in files:
print(filename)
if filename.find('wav') <= 0:
continue
elif filename.find('shift') > 0:
continue
result, longest_note = find_all_note_lines(filename)
base_frames = onsets_base_frames_for_note(filename)
print("base_frames is {}".format(base_frames))
base_notes = base_note(filename)
base_notes = [x - (base_notes[0] - longest_note[0]) for x in base_notes]
print("base_notes is {}".format(base_notes))
d, cost_matrix, acc_cost_matrix, path = dtw(longest_note, base_notes, dist=euclidean_norm)
if int(score) >=90:
grade = 'A'
files_list_a.append([filename + ' - ' + grade, score, lost_score, ex_score, min_d])
elif int(score) >= 75:
grade = 'B'
files_list_b.append([filename + ' - ' + grade, score, lost_score, ex_score, min_d])
elif int(score) >=60:
grade = 'C'
files_list_c.append([filename + ' - ' + grade, score, lost_score, ex_score, min_d])
elif int(score) >=1:
grade = 'D'
files_list_d.append([filename + ' - ' + grade, score, lost_score, ex_score, min_d])
else:
grade = 'E'
t1 = np.append(files_list_a,files_list_b).reshape(len(files_list_a)+len(files_list_b),5)
t2 = np.append(files_list_c,files_list_d).reshape(len(files_list_c)+len(files_list_d),5)
files_list = np.append(t1,t2).reshape(len(t1)+len(t2),5)
write_txt(files_list, new_old_txt, mode='w')