-
Notifications
You must be signed in to change notification settings - Fork 2
/
prepro.py
35 lines (28 loc) · 898 Bytes
/
prepro.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
'''
modified from
https://www.github.com/kyubyong/tacotron
'''
from __future__ import print_function
from utils import load_spectrograms
import os
from data_load import load_data
import numpy as np
import tqdm
from hyperparams import Hyperparams as hp
import sys
if not os.path.exists(hp.prepro_path): os.mkdir(hp.prepro_path)
mel_path = os.path.join(hp.prepro_path, "mels")
mag_path = os.path.join(hp.prepro_path, "mags")
# Load data
fpaths, _, _ = load_data() # list
if not os.path.exists(mel_path): os.mkdir(mel_path)
if not os.path.exists(mag_path): os.mkdir(mag_path)
for fpath in tqdm.tqdm(fpaths):
try:
fname, mel, mag = load_spectrograms(fpath)
except:
print(fpath + "\n")
sys.stdout.flush()
continue
np.save(mel_path + "/{}".format(fname.replace("wav", "npy")), mel)
np.save(mag_path + "/{}".format(fname.replace("wav", "npy")), mag)