forked from alitavanaali/MusiComb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
120 lines (107 loc) · 3.16 KB
/
generate.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
import argparse
from datetime import datetime
from pathlib import Path
import yaml
from commu_dset import DSET
#from commu_wrapper import make_midis
from musicomb import MusiComb
def main(args: argparse.Namespace, timestamp: str) -> None:
if args.generate_samples:
pass
# role_to_midis = make_midis(
# args.bpm,
# args.key,
# args.time_signature,
# args.num_measures,
# args.genre,
# args.rhythm,
# args.chord_progression,
# timestamp)
else:
role_to_midis = DSET.sample_midis(
args.bpm,
args.key,
args.time_signature,
args.num_measures,
args.genre,
args.rhythm,
args.chord_progression)
MusiComb(role_to_midis, timestamp, args.bpm, args.time_signature, args.num_measures, args.genre, args.music_length).solve()
if __name__ == '__main__':
with open('cfg/metadata_nv.yaml') as f:
meta = yaml.safe_load(f)
# now = datetime.now().strftime('%Y-%m-%d_%H.%M.%S')
# Path(f'out/{now}').mkdir(parents=True)
# # with open(f'out/{now}/metadata.yaml', 'w') as f:
# # yaml.dump(vars(args), f)
# main({
# "key" : "aminor",
# "bpm" : 90,
# "time_signature" : "4/4",
# "num_measures" : 8,
# "genre" : "cinematic",
# "rhythm" : "standard",
# "chord_progression" : "Am-G-F-C-Dm-Am-A#-Am",
# "generate_samples" : False,
# "music_length" : 2
# }, now)
parser = argparse.ArgumentParser()
parser.add_argument(
'--bpm',
dest='bpm',
type=int,
required=True,
choices=meta['bpm'])
parser.add_argument(
'--key',
dest='key',
type=str,
required=True,
choices=meta['key'])
parser.add_argument(
'--time_signature',
dest='time_signature',
type=str,
required=True,
choices=meta['time_signature'])
parser.add_argument(
'--num_measures',
dest='num_measures',
type=int,
required=True,
choices=meta['num_measures'])
parser.add_argument(
'--genre',
dest='genre',
type=str,
required=True,
choices=meta['genre'])
parser.add_argument(
'--rhythm',
dest='rhythm',
type=str,
required=True,
choices=meta['rhythm'])
parser.add_argument(
'--chord_progression',
dest='chord_progression',
type=str,
required=True,
choices=meta['chord_progression'])
parser.add_argument(
'--music_length',
dest='music_length',
type=int,
required=True,
choices=meta['music_length'])
parser.add_argument(
'--generate_samples',
dest='generate_samples',
default=False,
action='store_true')
args = parser.parse_args()
now = datetime.now().strftime('%Y-%m-%d_%H.%M.%S')
Path(f'out/{now}').mkdir(parents=True)
with open(f'out/{now}/metadata.yaml', 'w') as f:
yaml.dump(vars(args), f)
main(args, now)