Skip to content

Commit b24c7b4

Browse files
committed
Remove --has-gain and --passthrough-size args
Couldn't be used anymore
1 parent 2f8b36d commit b24c7b4

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

dnn/torch/fargan/fargan.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,13 @@ def forward(self, features, period):
154154
return tmp
155155

156156
class FARGANSub(nn.Module):
157-
def __init__(self, subframe_size=40, nb_subframes=4, cond_size=256, passthrough_size=0, has_gain=False):
157+
def __init__(self, subframe_size=40, nb_subframes=4, cond_size=256):
158158
super(FARGANSub, self).__init__()
159159

160160
self.subframe_size = subframe_size
161161
self.nb_subframes = nb_subframes
162162
self.cond_size = cond_size
163-
self.has_gain = has_gain
164-
self.passthrough_size = passthrough_size
165163

166-
#print("has_gain:", self.has_gain)
167-
#print("passthrough_size:", self.passthrough_size)
168164
#self.sig_dense1 = nn.Linear(4*self.subframe_size+self.passthrough_size+self.cond_size, self.cond_size, bias=False)
169165
self.fwc0 = FWConv(4*self.subframe_size+80, self.cond_size)
170166
self.sig_dense2 = nn.Linear(self.cond_size, self.cond_size, bias=False)
@@ -179,9 +175,8 @@ def __init__(self, subframe_size=40, nb_subframes=4, cond_size=256, passthrough_
179175
self.gru3_glu = GLU(self.cond_size)
180176
self.ptaps_dense = nn.Linear(4*self.cond_size, 5)
181177

182-
self.sig_dense_out = nn.Linear(4*self.cond_size, self.subframe_size+self.passthrough_size, bias=False)
183-
if self.has_gain:
184-
self.gain_dense_out = nn.Linear(4*self.cond_size, 1)
178+
self.sig_dense_out = nn.Linear(4*self.cond_size, self.subframe_size, bias=False)
179+
self.gain_dense_out = nn.Linear(4*self.cond_size, 1)
185180

186181

187182
self.apply(init_weights)
@@ -223,10 +218,9 @@ def forward(self, cond, prev, exc_mem, phase, period, states, gain=None):
223218
#fpitch = taps[:,0:1]*pred[:,:-4] + taps[:,1:2]*pred[:,1:-3] + taps[:,2:3]*pred[:,2:-2] + taps[:,3:4]*pred[:,3:-1] + taps[:,4:]*pred[:,4:]
224219
fpitch = pred[:,2:-2]
225220

226-
if self.has_gain:
227-
pitch_gain = torch.exp(self.gain_dense_out(gru3_out))
228-
dump_signal(pitch_gain, 'pgain.f32')
229-
sig_out = (sig_out + pitch_gain*fpitch) * gain
221+
pitch_gain = torch.exp(self.gain_dense_out(gru3_out))
222+
dump_signal(pitch_gain, 'pgain.f32')
223+
sig_out = (sig_out + pitch_gain*fpitch) * gain
230224
exc_mem = torch.cat([exc_mem[:,self.subframe_size:], sig_out], 1)
231225
dump_signal(sig_out, 'sig_out.f32')
232226
return sig_out, exc_mem, (gru1_state, gru2_state, gru3_state, fwc0_state)
@@ -240,11 +234,9 @@ def __init__(self, subframe_size=40, nb_subframes=4, feature_dim=20, cond_size=2
240234
self.frame_size = self.subframe_size*self.nb_subframes
241235
self.feature_dim = feature_dim
242236
self.cond_size = cond_size
243-
self.has_gain = has_gain
244-
self.passthrough_size = passthrough_size
245237

246238
self.cond_net = FARGANCond(feature_dim=feature_dim, cond_size=cond_size)
247-
self.sig_net = FARGANSub(subframe_size=subframe_size, nb_subframes=nb_subframes, cond_size=cond_size, has_gain=has_gain, passthrough_size=passthrough_size)
239+
self.sig_net = FARGANSub(subframe_size=subframe_size, nb_subframes=nb_subframes, cond_size=cond_size)
248240

249241
def forward(self, features, period, nb_frames, pre=None, states=None):
250242
device = features.device
@@ -266,7 +258,6 @@ def forward(self, features, period, nb_frames, pre=None, states=None):
266258

267259
sig = torch.zeros((batch_size, 0), device=device)
268260
cond = self.cond_net(features, period)
269-
passthrough = torch.zeros(batch_size, self.passthrough_size, device=device)
270261
if pre is not None:
271262
prev[:,:] = pre[:, self.frame_size-self.subframe_size : self.frame_size]
272263
exc_mem[:,-self.frame_size:] = pre[:, :self.frame_size]

dnn/torch/fargan/train_fargan.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
model_group = parser.add_argument_group(title="model parameters")
2626
model_group.add_argument('--cond-size', type=int, help="first conditioning size, default: 256", default=256)
27-
model_group.add_argument('--has-gain', action='store_true', help="use gain-shape network")
28-
model_group.add_argument('--passthrough-size', type=int, help="state passing through in addition to audio, default: 0", default=0)
2927
model_group.add_argument('--gamma', type=float, help="Use A(z/gamma), default: 0.9", default=0.9)
3028

3129
training_group = parser.add_argument_group(title="training parameters")
@@ -74,7 +72,7 @@
7472
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
7573

7674
checkpoint['model_args'] = ()
77-
checkpoint['model_kwargs'] = {'cond_size': cond_size, 'has_gain': args.has_gain, 'passthrough_size': args.passthrough_size, 'gamma': args.gamma}
75+
checkpoint['model_kwargs'] = {'cond_size': cond_size, 'gamma': args.gamma}
7876
print(checkpoint['model_kwargs'])
7977
model = fargan.FARGAN(*checkpoint['model_args'], **checkpoint['model_kwargs'])
8078

0 commit comments

Comments
 (0)