-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprepare_all_shoutouts.py
49 lines (35 loc) · 1.54 KB
/
prepare_all_shoutouts.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
#!/usr/bin/env python3
import argparse
import csv
import multiprocessing
import os
import subprocess
err = subprocess.Popen(['pip', 'install', 'ffmpeg'],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE).communicate()[1]
if len(err) != 0:
print(err)
exit(1)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-input', type=str, default=os.path.join(os.path.curdir, 'shoutouts'), help='Input folder')
parser.add_argument('-output', type=str, default=os.path.join(os.path.curdir, 'prepared_shoutouts'),
help='Output folder')
parser.add_argument('-t', type=int, default=-14, help='Target volume in LUFS (-70 to -5)')
args = parser.parse_args()
from prepare_shoutout import prepare_shoutout
if not os.path.exists(args.input):
exit(1)
if not os.path.exists(args.output):
os.mkdir(args.output)
with multiprocessing.Pool() as p:
with open('klub.csv', 'rt') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
for i, row in enumerate(reader, 1):
infile = os.path.join(args.input, str(i) + '.wav')
outfile = os.path.join(args.output, str(i) + '.wav')
if not os.path.exists(infile):
continue
p.apply_async(prepare_shoutout, (infile, outfile, args.t))
p.close()
p.join()