-
Notifications
You must be signed in to change notification settings - Fork 0
/
inference.py
50 lines (47 loc) · 1.51 KB
/
inference.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
from pianogen.pianogen import MidiParser, MidiFileProcessor
import argparse
import warnings
warnings.filterwarnings("ignore")
def functiones(args):
mode = 'process'
#Process
if mode == args.mode:
print('Beginning Processing phase, please wait ......')
processor = MidiFileProcessor(args.filepath)
processor.get_listItems(args.tracks)
print('writing dumps to utilities directory 8)')
#Parse
else:
print('Beginning Parsing phase, please wait ......')
drive = MidiParser(args.output) # parser object
drive.parse() # parse the midi dir based on the json conditional list of same track files
# you will endup with a pianoroll dataset at the root of your project dir
print('writing npz to root directory 8)')
def main():
"""Parse and return the command line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--filepath",type=str, default='midis', help="Path to your midi files.")
parser.add_argument(
"-t",
"--tracks",
type=int,
default=0,
help="Number of tracks.",
)
parser.add_argument(
"-o",
"--output",
type=str,
default='train_x_phr.npz',
help="output fname of your pianoroll.",
)
parser.add_argument(
"--mode",
type=str,
default='process',
help="mode processing or parsing.",
)
args = parser.parse_args()
functiones(args)
if __name__ == '__main__':
main()