forked from text-to-speech/dc_tts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepro.py
37 lines (28 loc) · 1.2 KB
/
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
35
36
37
# -*- coding: utf-8 -*-
#/usr/bin/python2
'''
By kyubyong park. kbpark.linguist@gmail.com.
https://www.github.com/kyubyong/dc_tts
'''
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
# Load data
fpaths, _, _ = load_data() # list
for fpath in tqdm.tqdm(fpaths):
fname, mel, mag = load_spectrograms(fpath)
#os.mkdir(hp.data+"mels", exist_ok=True)
#os.mkdir(hp.data+"mags", exist_ok=True)
num = int(fname.split('-')[-1].split('.')[0])
folder_num = num // 1000
subfolder_num = (num % 1000) // 100
#os.mkdir(hp.data+"mels/"+str(folder_num), exist_ok=True)
#os.mkdir(hp.data+"mags/"+str(folder_num), exist_ok=True)
os.makedirs(hp.data+"mels/"+str(folder_num)+"/"+str(subfolder_num), exist_ok=True)
os.makedirs(hp.data+"mags/"+str(folder_num)+"/"+str(subfolder_num), exist_ok=True)
np.save(hp.data+"mels/"+str(folder_num)+"/"+str(subfolder_num)+"/"+"{}".format(fname.replace(".wav", ".npy")), mel)
np.save(hp.data+"mags/"+str(folder_num)+"/"+str(subfolder_num)+"/"+"{}".format(fname.replace(".wav", ".npy")), mag)