-
Notifications
You must be signed in to change notification settings - Fork 19
/
preprocess.py
53 lines (40 loc) · 1.43 KB
/
preprocess.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
import os
import copy
import logging
import numpy as np
import pyworld as pw
import resemblyzer
from glob import glob
from tqdm import tqdm
from functools import partial
from multiprocessing.pool import ThreadPool
from util.parser import get_parser
from util.config import Config
from util.dsp import Dsp
from preprocessor import get_preprocessor
logging.basicConfig(level=logging.INFO, format='[%(levelname)s] %(name)s - %(message)s')
logger = logging.getLogger(__name__)
def get_args():
parser = get_parser(description='Preprocess')
# config
parser.add_argument('--config', '-c', default='./config/preprocess.yaml', help='config yaml file')
# multi thread
parser.add_argument('--njobs', '-p', type=int, default=4)
return parser.parse_args()
if __name__ == '__main__':
# config
args = get_args()
config = Config(args.config)
# build preprocessor
preprocessor = get_preprocessor(config)
# process
for feat in config.feat_to_preprocess:
preprocessor.preprocess(input_path=config.input_path, output_path=config.output_path, feat=feat, njobs=args.njobs)
# # For debugging, only use one file.
# input_path = config.input_path
# output_path = config.output_path
# feat = 's3prl_mockingjay'
# fin = os.path.join(input_path, 'p317/p317_424.wav')
# fout = os.path.join(output_path, feat)
# print(fin, fout)
# process_one(fin, processor.dsp_modules[feat], fout)