-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker.py
62 lines (54 loc) · 2.66 KB
/
checker.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
from dotenv import load_dotenv
import os
# Access environmental variables
load_dotenv(verbose=True)
input_path = os.environ.get('pathname')
output_path = os.environ.get('dataname')
YEARS = [2004, 2006, 2008, 2009, 2011, 2013, 2014, 2015, 2017, 2018]
passed = True
for year in YEARS:
try:
year = str(year)
files = os.listdir(os.path.join(input_path, year))
NOTE_GRAPHS_PATH = os.path.join(output_path, 'note_graphs', year) + "/"
NOTES_GENERATED_PATH = os.path.join(
output_path, 'notes_generated', year) + "/"
SPECTROGRAM_GENERATED_PATH = os.path.join(
output_path, 'spectrograms_generated', year) + "/"
SPECTROGRAM_REAL_PATH = os.path.join(
output_path, 'spectrograms_real', year) + "/"
GENERATED_AUDIO_PATH = os.path.join(
output_path, 'generated_audio', year) + "/"
assert(len(files)%2 == 0)
print(f"Year:{year} Expected:{len(files) // 2}")
print(f"generated_audio:{len(os.listdir(GENERATED_AUDIO_PATH))} "+\
f"note_graphs:{len(os.listdir(NOTE_GRAPHS_PATH))} " +\
f"notes_generated:{len(os.listdir((NOTES_GENERATED_PATH)))} "+\
f"spectrograms_generated:{len(os.listdir((SPECTROGRAM_GENERATED_PATH)))} "+\
f"spectrograms_real:{len(os.listdir((SPECTROGRAM_REAL_PATH)))} "
)
passed = passed and len(files)//2 ==\
len(os.listdir(GENERATED_AUDIO_PATH)) ==\
len(os.listdir(NOTE_GRAPHS_PATH)) ==\
len(os.listdir(NOTES_GENERATED_PATH)) ==\
len(os.listdir(SPECTROGRAM_GENERATED_PATH)) ==\
len(os.listdir(SPECTROGRAM_REAL_PATH))
# check if spectrogram real and generated match
print("--------------------------")
print("Checking generated spectrograms...")
for spec in os.listdir(SPECTROGRAM_REAL_PATH):
if spec not in os.listdir(SPECTROGRAM_GENERATED_PATH):
print(f"Spectrogram {spec} not found in generated spectrograms")
passed = False
# check if spectrogram real and note graph match
print("--------------------------")
print("Checking note graphs...")
for spec in os.listdir(SPECTROGRAM_REAL_PATH):
if spec not in os.listdir(NOTE_GRAPHS_PATH):
print(f"Spectrogram {spec} not found in note graphs")
passed = False
except FileNotFoundError:
print(f"is missing")
passed = False
print("--------------------------")
print("Passed!" if passed else "Failed!")