Skip to content

Commit a929bbc

Browse files
author
Rick-McCoy
committed
Changed MelGen to only deal with numpy
1 parent d8d8002 commit a929bbc

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

datasets/wavloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def __init__(self, hp, args, train):
3939
random.seed(123)
4040
random.shuffle(self.file_list)
4141
if train:
42-
self.file_list = self.file_list[:int(0.95*len(self.file_list))]
42+
self.file_list = self.file_list[:int(0.95 * len(self.file_list))]
4343
else:
44-
self.file_list = self.file_list[int(0.95*len(self.file_list)):]
44+
self.file_list = self.file_list[int(0.95 * len(self.file_list)):]
4545

4646
self.wavlen = int(hp.audio.sr * hp.audio.duration)
4747
self.tier = self.args.tier

utils/audio.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# based on https://github.com/keithito/tacotron/blob/master/util/audio.py
22

3-
import torch
43
import librosa
54
import numpy as np
65

@@ -18,7 +17,6 @@ def get_normalized_mel(self, x):
1817
win_length=self.hp.audio.win_length,
1918
n_mels=self.hp.audio.n_mels
2019
)
21-
x = torch.from_numpy(x)
2220
x = self.pre_spec(x)
2321
return x
2422

@@ -29,13 +27,13 @@ def post_spec(self, x):
2927
return self.db_to_amp(self.denormalize(x) + self.hp.audio.ref_level_db)
3028

3129
def amp_to_db(self, x):
32-
return 20.0 * torch.log10(torch.max(x, torch.tensor(1e-6)))
30+
return 20.0 * np.log10(np.maximum(x, 1e-6))
3331

3432
def normalize(self, x):
35-
return torch.clamp(x / -self.hp.audio.min_level_db, -1.0, 0.0) + 1.0
33+
return np.clip(x / -self.hp.audio.min_level_db, -1.0, 0.0) + 1.0
3634

3735
def db_to_amp(self, x):
38-
return torch.pow(10.0, 0.05*x)
36+
return np.power(10.0, 0.05 * x)
3937

4038
def denormalize(self, x):
41-
return (torch.clamp(x, 0.0, 1.0) - 1.0) * -self.hp.audio.min_level_db
39+
return (np.clip(x, 0.0, 1.0) - 1.0) * -self.hp.audio.min_level_db

utils/train.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def train(args, pt_dir, chkpt_path, trainloader, testloader, writer, logger, hp,
7979
optimizer.zero_grad()
8080
loss_sum = 0
8181
for epoch in itertools.count(init_epoch+1):
82-
trainloader.tier = args.tier
8382
loader = tqdm(trainloader, desc='Train data loader')
8483
for source, target in loader:
8584
mu, std, pi = model(source.cuda())

0 commit comments

Comments
 (0)