Skip to content

Commit 46475bb

Browse files
authoredFeb 8, 2018
prepro added
1 parent cce237d commit 46475bb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
 

‎data_load.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,17 @@ def get_batch():
100100

101101
# Parse
102102
text = tf.decode_raw(text, tf.int32) # (None,)
103-
fname, mel, mag = tf.py_func(load_spectrograms, [fpath], [tf.string, tf.float32, tf.float32]) # (None, n_mels)
103+
104+
if hp.prepro:
105+
def _load_spectrograms(fpath):
106+
fname = os.path.basename(fpath)
107+
mel = "mels/{}".format(fname.replace("wav", "npy"))
108+
mag = "mags/{}".format(fname.replace("wav", "npy"))
109+
return fname, np.load(mel), np.load(mag)
110+
111+
fname, mel, mag = tf.py_func(_load_spectrograms, [fpath], [tf.string, tf.float32, tf.float32])
112+
else:
113+
fname, mel, mag = tf.py_func(load_spectrograms, [fpath], [tf.string, tf.float32, tf.float32]) # (None, n_mels)
104114

105115
# Add shape information
106116
fname.set_shape(())

‎prepo.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
#/usr/bin/python2
3+
'''
4+
By kyubyong park. kbpark.linguist@gmail.com.
5+
https://www.github.com/kyubyong/dc_tts
6+
'''
7+
8+
from __future__ import print_function
9+
10+
from utils import load_spectrograms
11+
import os
12+
from data_load import load_data
13+
import numpy as np
14+
import tqdm
15+
16+
# Load data
17+
fpaths, _, _ = load_data() # list
18+
19+
for fpath in tqdm.tqdm(fpaths):
20+
fname, mel, mag = load_spectrograms(fpath)
21+
if not os.path.exists("mels"): os.mkdir("mels")
22+
if not os.path.exists("mags"): os.mkdir("mags")
23+
24+
np.save("mels/{}".format(fname.replace("wav", "npy")), mel)
25+
np.save("mags/{}".format(fname.replace("wav", "npy")), mag)

0 commit comments

Comments
 (0)
Please sign in to comment.