-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathdataset.py
663 lines (487 loc) · 22.7 KB
/
dataset.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
import os
import sys
import numpy as np
import argparse
import re
import string
import time
import csv
import glob
from bs4 import BeautifulSoup
import nltk
from nltk.tokenize import RegexpTokenizer
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
from config import nationalities
def space_to_underscore(s):
return s.replace(' ', '_')
def underscore_to_space(s):
return s.replace('_', ' ')
def download_imslp_htmls(args):
"""Download html pages of all composers on IMSLP. In total 18,399 html
pages have been downloaded.
"""
# Arguments & parameters
workspace = args.workspace
# Paths
htmls_dir = os.path.join(workspace, 'htmls')
os.makedirs(htmls_dir, exist_ok=True)
# Download composer page
html_path = os.path.join(workspace, 'Category:Composers.html')
os.system('wget --quiet -O {} https://imslp.org/wiki/Category:Composers'.format(html_path))
# Load html text
with open(html_path, 'r') as fr:
text = fr.read()
# Get all composer names. Will looks like:
# ['A., Jag', 'Aadler, C. A.', 'Aagesen, Truid', ...]
names = []
for ch in string.ascii_uppercase[0 : 26]:
"""Search from A to Z. Get all composers by their surnames."""
substring = text[re.search(f'"{ch}":\[', text).end() :]
substring = substring[: re.search('\]', substring).start()]
substring = substring.encode('utf8').decode('unicode_escape')
names += substring[1 : -1].split('","')
bgn_time = time.time()
# Download html pages of all composers
for n, name in enumerate(names):
surname_firstname = name.split(', ')
"""E.g., ['A.', 'Jag']"""
if len(surname_firstname) == 1:
surname = surname_firstname[0]
composer_link = 'https://imslp.org/wiki/Category:{}'.format(space_to_underscore(surname))
html_path = os.path.join(htmls_dir, '{}.html'.format(surname))
elif len(surname_firstname) == 2:
[surname, firstname] = surname_firstname
composer_link = 'https://imslp.org/wiki/Category:{}%2C_{}'.format(
space_to_underscore(surname), space_to_underscore(firstname))
html_path = os.path.join(htmls_dir, '{}, {}.html'.format(surname, firstname))
os.system('wget --quiet -O "{}" "{}"'.format(html_path, composer_link))
print(n, html_path, os.path.isfile(html_path))
print('Finish! {:.3f} s'.format(time.time() - bgn_time))
def download_wikipedia_htmls(args):
"""Download wikipedia pages of composers if exist. In total 6,831 wikipedia
pages are downloaded."""
# Arguments & parameters
workspace = args.workspace
# Paths
htmls_dir = os.path.join(workspace, 'htmls')
html_names = sorted(os.listdir(htmls_dir))
wikipedias_dir = os.path.join(workspace, 'wikipedias')
os.makedirs(wikipedias_dir, exist_ok=True)
# Download wikipedia of composers
for n, html_name in enumerate(html_names):
print(n, html_name) # E.g., 'A., Jag.html'
html_path = os.path.join(htmls_dir, html_name)
surname_firstname = html_name[0 : -5].split(', ')
if len(surname_firstname) == 2:
[surname, firstname] = surname_firstname
with open(html_path, 'r') as fr:
text = fr.read()
tmp = re.search('Detailed biography: <a href="', text)
if tmp: # Only part of composer has wikipedia page
text = text[tmp.end() : tmp.end() + 500]
wikipedia_link = text[: re.search('"', text).start()]
print(wikipedia_link)
out_path = os.path.join(wikipedias_dir, '{}, {}.html'.format(surname, firstname))
os.system('wget --quiet -O "{}" "{}"'.format(out_path, wikipedia_link))
def create_meta_csv(args):
"""Create GiantMIDI-Piano meta csv. This csv collects 144,079 music pieces
from all composers."""
# Arguments & parameters
workspace = args.workspace
# Paths
htmls_dir = os.path.join(workspace, 'htmls')
wikipedias_dir = os.path.join(workspace, 'wikipedias')
out_csv_path = os.path.join(workspace, 'full_music_pieces.csv')
html_names = sorted(os.listdir(htmls_dir))
meta_dict = {'surname': [], 'firstname': [], 'music': [], 'nationality': [],
'birth': [], 'death': []}
for n, html_name in enumerate(html_names):
print(n, html_name) # E.g., 'A., Jag.html'
surname_firstname = html_name[0 : -5].split(', ')
if len(surname_firstname) == 2:
[surname, firstname] = surname_firstname
# Parse nationality, birth and death from Wikipedia
wikipedia_path = os.path.join(wikipedias_dir, '{}, {}.html'.format(surname, firstname))
(nationality, birth, death) = get_composer_info_from_wikipedia(wikipedia_path)
# Parse music pieces from IMSLP html
html_path = os.path.join(htmls_dir, html_name)
music_names = get_music_names_from_imslp(html_path)
music_names = [remove_suffix(music_name, firstname, surname) for music_name in music_names]
for music_name in music_names:
meta_dict['surname'].append(surname)
meta_dict['firstname'].append(firstname)
meta_dict['music'].append(music_name)
meta_dict['nationality'].append(nationality)
meta_dict['birth'].append(birth)
meta_dict['death'].append(death)
write_meta_dict_to_csv(meta_dict, out_csv_path)
print('Write out to {}'.format(out_csv_path))
def get_composer_info_from_wikipedia(wikipedia_path):
"""Get nationality, birth and death from wikipedia."""
nationality = None
years = []
if os.path.isfile(wikipedia_path):
with open(wikipedia_path, 'r') as fr:
text = fr.read()
text = text.replace(': ', ':')
text = text.replace('", "', '","')
bgn = re.search('wgCategories":\[', text)
if not bgn:
return 'unknown', 'unknown', 'unknown'
bgn = bgn.end()
text = text[bgn + 1 :]
fin = re.search('\]', text).start()
text = text[0 : fin - 1]
text = text.split('","')
sentence = ' '.join(text)
words = nltk.word_tokenize(sentence)
pairs = nltk.pos_tag(words)
for pair in pairs:
if pair[1] == 'JJ': # Nationality
if not nationality and pair[0] in nationalities:
nationality = pair[0]
elif pair[1] == 'CD': # Birth or death year
try:
year = int(pair[0][0:4])
if year >= 1000 and year <= 9999:
years.append(year)
except:
pass
years = sorted(years)
if len(years) >= 2:
birth = str(years[0])
death = str(years[1])
else:
birth = 'unknown'
death = 'unknown'
if not nationality:
nationality = 'unknown'
return nationality, birth, death
def get_music_names_from_imslp(ismlp_path):
"""Get all music names of a composer by parsing his / her IMSLP html page."""
with open(ismlp_path, 'r') as fr:
text = fr.read()
# All music pieces information are before catpagejs
obj = re.search("</div><script>if\(typeof catpagejs=='undefined'\)", text)
if obj:
text = text[: obj.start()]
soup = BeautifulSoup(text, 'html.parser')
links = soup.find_all('a')
music_names = []
for link in links:
link = str(link)
if 'categorypagelink' in link:
"""link looks like: '<a class="categorypagelink" href="/wiki/Je_t%27aime_Juliette_(A.,_Jag)" title="Je t\'aime Juliette (A., Jag)">Je t\'aime Juliette (A., Jag)</a>'
"""
bgn = re.search('title=', link).end()
link = link[bgn + 1 :]
fin = re.search('>', link).start()
music_name = link[0 : fin - 1] # "Je t'aime Juliette (A., Jag)"
music_names.append(music_name)
for link in links:
link = str(link)
if 'next 200' in link:
"""link looks like: '<a class="categorypaginglink" href="/index.php?title=Category:Mozart,_Wolfgang_Amadeus&pagefrom=Fantasia+in+f+minor%2C+k.0608%7E%7Emozart%2C+wolfgang+amadeus%0AFantasia+in+F+minor%2C+K.608+%28Mozart%2C+Wolfgang+Amadeus%29#mw-pages" title="Category:Mozart, Wolfgang Amadeus">next 200</a>'
"""
bgn = re.search('href="', link).end()
link = link[bgn :]
fin = re.search('"', link).start()
link = link[: fin]
link = 'https://imslp.org{}'.format(link)
link = link.replace('&', '&')
print(link)
os.system('wget --quiet -O _tmp.html "{}"'.format(link))
music_names += get_music_names_from_imslp('_tmp.html')
break
return music_names
def remove_suffix(music_name, firstname, surname):
loct = re.search(f' \({surname}, {firstname}\)', music_name)
if loct:
music_name = music_name[0 : loct.start()]
return music_name
def write_meta_dict_to_csv(meta_dict, out_csv_path):
"""Write meta dict to csv path."""
with open(out_csv_path, 'w') as fw:
line = '\t'.join([key for key in meta_dict.keys()])
fw.write('{}\n'.format(line))
for n in range(len(meta_dict['firstname'])):
line = '\t'.join([str(meta_dict[key][n]) for key in meta_dict.keys()])
fw.write('{}\n'.format(line))
def read_csv_to_meta_dict(csv_path):
"""Read csv file to meta_dict."""
lines = []
with open(csv_path, 'r') as fr:
for line in fr.readlines():
line = line.split('\n')[0].split('\t')
lines.append(line)
meta_dict = {key: [] for key in lines[0]}
lines = lines[1 :]
for m, line in enumerate(lines):
for k, key in enumerate(meta_dict.keys()):
meta_dict[key].append(line[k])
return meta_dict
def _read_title_id(path):
with open(path, 'r') as fr:
lines = fr.readlines()
if len(lines) == 2:
title = lines[0].split('\n')[0]
id = lines[1].split('\n')[0]
return title, id
else:
return 'none', 'none'
def _too_many_requests(path):
with open(path, 'r') as fr:
lines = fr.readlines()
for line in lines:
print(line)
if 'HTTP Error 429: Too Many Requests' in line:
return True
return False
def search_youtube(args):
"""Search music names on YouTube, and append searched YouTube titles and
IDs to meta csv."""
# Arguments & parameters
workspace = args.workspace
mini_data = args.mini_data
if mini_data:
prefix = 'minidata_'
else:
prefix = ''
# Paths
csv_path = os.path.join(workspace, 'full_music_pieces.csv')
stdout_path = os.path.join(workspace, '_tmp', 'stdout.txt')
error_path = os.path.join(workspace, '_tmp', 'error.txt')
os.makedirs(os.path.dirname(stdout_path), exist_ok=True)
youtube_csv_path = os.path.join(workspace, '{}full_music_pieces_youtube.csv'.format(prefix))
meta_dict = read_csv_to_meta_dict(csv_path)
youtube_meta_dict = {key: [] for key in meta_dict.keys()}
youtube_meta_dict['youtube_title'] = []
youtube_meta_dict['youtube_id'] = []
n = 0
while n < len(meta_dict['surname']):
print(n, meta_dict['surname'][n])
search_str = '{} {}, {}'.format(meta_dict['firstname'][n],
meta_dict['surname'][n], meta_dict['music'][n])
youtube_simulate_str = 'youtube-dl --get-id --get-title ytsearch$1:"{}" 1>"{}" 2>"{}"'.\
format(search_str, stdout_path, error_path)
os.system(youtube_simulate_str)
if _too_many_requests(error_path):
sleep_seconds = 3600
print('Too many requests! Sleep for {} s ...'.format(sleep_seconds))
time.sleep(sleep_seconds)
continue
(title, id) = _read_title_id(stdout_path)
youtube_meta_dict['youtube_title'].append(title)
youtube_meta_dict['youtube_id'].append(id)
for key in meta_dict.keys():
youtube_meta_dict[key].append(meta_dict[key][n])
print(', '.join([youtube_meta_dict[key][n] for key in youtube_meta_dict.keys()]))
n += 1
if mini_data and n == 10:
break
write_meta_dict_to_csv(youtube_meta_dict, youtube_csv_path)
print('Write out to {}'.format(youtube_csv_path))
def intersection(lst1, lst2):
lst3 = [value for value in lst1 if value in lst2]
return lst3
def jaccard_similarity(x, y):
intersect = intersection(x, y)
similarity = len(intersect) / max(float(len(x)), 1e-8)
return similarity
def calculate_similarity(args):
"""Calculate and append the similarity between YouTube titles and IMSLP
music names to meta csv."""
# Arguments & parameters
workspace = args.workspace
mini_data = args.mini_data
if mini_data:
prefix = 'minidata_'
else:
prefix = ''
# Paths
youtube_csv_path = os.path.join(workspace,
'{}full_music_pieces_youtube.csv'.format(prefix))
similarity_csv_path = os.path.join(workspace,
'{}full_music_pieces_youtube_similarity.csv'.format(prefix))
# Meta info to be downloaded
meta_dict = read_csv_to_meta_dict(youtube_csv_path)
meta_dict['similarity'] = []
meta_dict['surname_in_youtube_title'] = []
tokenizer = RegexpTokenizer('[A-Za-z0-9ÇéâêîôûàèùäëïöüÄß]+')
count = 0
download_time = time.time()
for n in range(len(meta_dict['surname'])):
target_str = '{} {}, {}'.format(meta_dict['firstname'][n],
meta_dict['surname'][n], meta_dict['music'][n])
target_str_without_firstname = '{}, {}'.format(
meta_dict['surname'][n], meta_dict['music'][n])
searched_str = meta_dict['youtube_title'][n]
target_words = tokenizer.tokenize(target_str_without_firstname.lower())
searched_words = tokenizer.tokenize(searched_str.lower())
similarity = jaccard_similarity(target_words, searched_words)
meta_dict['similarity'].append(str(similarity))
if meta_dict['surname'][n] in meta_dict['youtube_title'][n]:
meta_dict['surname_in_youtube_title'].append(1)
else:
meta_dict['surname_in_youtube_title'].append(0)
if meta_dict['surname'][n] in meta_dict['youtube_title'][n]:
meta_dict['surname_in_youtube_title'].append(1)
else:
meta_dict['surname_in_youtube_title'].append(0)
write_meta_dict_to_csv(meta_dict, similarity_csv_path)
print('Write out to {}'.format(similarity_csv_path))
def download_youtube(args):
"""Download IMSLP music pieces from YouTube. 59,969 files are downloaded
in Jan. 2020.
"""
# Arguments & parameters
workspace = args.workspace
begin_index = args.begin_index
end_index = args.end_index
mini_data = args.mini_data
if mini_data:
prefix = 'minidata_'
else:
prefix = ''
# Paths
similarity_csv_path = os.path.join(workspace,
'{}full_music_pieces_youtube_similarity.csv'.format(prefix))
mp3s_dir = os.path.join(workspace, 'mp3s')
os.makedirs(mp3s_dir, exist_ok=True)
stdout_path = os.path.join(workspace, '_tmp', 'stdout.txt')
error_path = os.path.join(workspace, '_tmp', 'error.txt')
os.makedirs(os.path.dirname(stdout_path), exist_ok=True)
# Meta info to be downloaded
meta_dict = read_csv_to_meta_dict(similarity_csv_path)
count = 0
download_time = time.time()
n = begin_index
while n < min(end_index, len(meta_dict['surname'])):
print('{}; {} {}; {}; {}'.format(n, meta_dict['firstname'][n],
meta_dict['surname'][n], meta_dict['music'][n], meta_dict['youtube_title'][n]))
if float(meta_dict['similarity'][n]) > 0.6:
count += 1
bare_name = os.path.join('{}, {}, {}, {}'.format(
meta_dict['surname'][n], meta_dict['firstname'][n],
meta_dict['music'][n], meta_dict['youtube_id'][n]).replace('/', '_'))
youtube_str = 'youtube-dl -f bestaudio -o "{}/{}.%(ext)s" https://www.youtube.com/watch?v={} 1>"{}" 2>"{}"' \
.format(mp3s_dir, bare_name, meta_dict['youtube_id'][n], stdout_path, error_path)
os.system(youtube_str)
if _too_many_requests(error_path):
sleep_seconds = 3600
print('Too many requests! Sleep for {} s ...'.format(sleep_seconds))
time.sleep(sleep_seconds)
continue
# Convert to MP3
audio_paths = glob.glob(os.path.join(mp3s_dir, '{}*'.format(bare_name)))
print(audio_paths)
if len(audio_paths) > 0:
audio_path = audio_paths[0]
mp3_path = os.path.join(mp3s_dir, '{}.mp3'.format(bare_name))
os.system('ffmpeg -i "{}" -loglevel panic -y -ac 1 -ar 32000 "{}" '\
.format(audio_path, mp3_path))
if os.path.splitext(audio_path)[-1] != '.mp3':
os.system('rm "{}"'.format(audio_path))
n += 1
print('{} out of {} audios are downloaded!'.format(count, end_index - begin_index))
print('Time: {:.3f}'.format(time.time() - download_time))
def download_youtube_piano_solo(args):
"""Download piano solo of GiantMIDI-Piano. 10,848 files can be downloaded in
Jan. 2020.
"""
# Arguments & parameters
workspace = args.workspace
begin_index = args.begin_index
end_index = args.end_index
mini_data = args.mini_data
if mini_data:
prefix = 'minidata_'
else:
prefix = ''
# Paths
similarity_csv_path = os.path.join(workspace,
'{}full_music_pieces_youtube_similarity_pianosoloprob.csv'.format(prefix))
mp3s_dir = os.path.join(workspace, 'mp3s_piano_solo')
os.makedirs(mp3s_dir, exist_ok=True)
stdout_path = os.path.join(workspace, '_tmp', 'stdout.txt')
error_path = os.path.join(workspace, '_tmp', 'error.txt')
os.makedirs(os.path.dirname(stdout_path), exist_ok=True)
# Meta info to be downloaded
meta_dict = read_csv_to_meta_dict(similarity_csv_path)
count = 0
download_time = time.time()
n = begin_index
while n < min(end_index, len(meta_dict['surname'])):
print('{}; {} {}; {}; {}'.format(n, meta_dict['firstname'][n],
meta_dict['surname'][n], meta_dict['music'][n], meta_dict['youtube_title'][n]))
if float(meta_dict['piano_solo_prob'][n]) >= 0.5:
count += 1
bare_name = os.path.join('{}, {}, {}, {}'.format(
meta_dict['surname'][n], meta_dict['firstname'][n],
meta_dict['music'][n], meta_dict['youtube_id'][n]).replace('/', '_'))
youtube_str = 'youtube-dl -f bestaudio -o "{}/{}.%(ext)s" https://www.youtube.com/watch?v={} 1>"{}" 2>"{}"' \
.format(mp3s_dir, bare_name, meta_dict['youtube_id'][n], stdout_path, error_path)
os.system(youtube_str)
if _too_many_requests(error_path):
sleep_seconds = 3600
print('Too many requests! Sleep for {} s ...'.format(sleep_seconds))
time.sleep(sleep_seconds)
continue
# Convert to MP3
audio_paths = glob.glob(os.path.join(mp3s_dir, '{}*'.format(bare_name)))
print(audio_paths)
if len(audio_paths) > 0:
audio_path = audio_paths[0]
mp3_path = os.path.join(mp3s_dir, '{}.mp3'.format(bare_name))
os.system('ffmpeg -i "{}" -loglevel panic -y -ac 1 -ar 32000 "{}" '\
.format(audio_path, mp3_path))
if os.path.splitext(audio_path)[-1] != '.mp3':
os.system('rm "{}"'.format(audio_path))
n += 1
print('{} out of {} audios are downloaded!'.format(count, end_index - begin_index))
print('Time: {:.3f}'.format(time.time() - download_time))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Example of parser. ')
subparsers = parser.add_subparsers(dest='mode')
# Plot statistics
parser_imslp_htmls = subparsers.add_parser('download_imslp_htmls')
parser_imslp_htmls.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_wikipedia = subparsers.add_parser('download_wikipedia_htmls')
parser_wikipedia.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_create_meta_csv = subparsers.add_parser('create_meta_csv')
parser_create_meta_csv.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_search = subparsers.add_parser('search_youtube')
parser_search.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_search.add_argument('--mini_data', action='store_true', default=False)
parser_similarity = subparsers.add_parser('calculate_similarity')
parser_similarity.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_similarity.add_argument('--mini_data', action='store_true', default=False)
parser_download_youtube = subparsers.add_parser('download_youtube')
parser_download_youtube.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_download_youtube.add_argument('--begin_index', type=int, default=0)
parser_download_youtube.add_argument('--end_index', type=int, required=True)
parser_download_youtube.add_argument('--mini_data', action='store_true', default=False)
parser_download_youtube_piano_solo = subparsers.add_parser('download_youtube_piano_solo')
parser_download_youtube_piano_solo.add_argument('--workspace', type=str, required=True, help='Directory of your workspace.')
parser_download_youtube_piano_solo.add_argument('--begin_index', type=int, default=0)
parser_download_youtube_piano_solo.add_argument('--end_index', type=int, required=True)
parser_download_youtube_piano_solo.add_argument('--mini_data', action='store_true', default=False)
# Parse arguments
args = parser.parse_args()
if args.mode == 'download_imslp_htmls':
download_imslp_htmls(args)
elif args.mode == 'download_wikipedia_htmls':
download_wikipedia_htmls(args)
elif args.mode == 'create_meta_csv':
create_meta_csv(args)
elif args.mode == 'search_youtube':
search_youtube(args)
elif args.mode == 'calculate_similarity':
calculate_similarity(args)
elif args.mode == 'download_youtube':
download_youtube(args)
elif args.mode == 'download_youtube_piano_solo':
download_youtube_piano_solo(args)
else:
raise Exception('Error argument!')