@@ -154,17 +154,13 @@ def forward(self, features, period):
154
154
return tmp
155
155
156
156
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 ):
158
158
super (FARGANSub , self ).__init__ ()
159
159
160
160
self .subframe_size = subframe_size
161
161
self .nb_subframes = nb_subframes
162
162
self .cond_size = cond_size
163
- self .has_gain = has_gain
164
- self .passthrough_size = passthrough_size
165
163
166
- #print("has_gain:", self.has_gain)
167
- #print("passthrough_size:", self.passthrough_size)
168
164
#self.sig_dense1 = nn.Linear(4*self.subframe_size+self.passthrough_size+self.cond_size, self.cond_size, bias=False)
169
165
self .fwc0 = FWConv (4 * self .subframe_size + 80 , self .cond_size )
170
166
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_
179
175
self .gru3_glu = GLU (self .cond_size )
180
176
self .ptaps_dense = nn .Linear (4 * self .cond_size , 5 )
181
177
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 )
185
180
186
181
187
182
self .apply (init_weights )
@@ -223,10 +218,9 @@ def forward(self, cond, prev, exc_mem, phase, period, states, gain=None):
223
218
#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:]
224
219
fpitch = pred [:,2 :- 2 ]
225
220
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
230
224
exc_mem = torch .cat ([exc_mem [:,self .subframe_size :], sig_out ], 1 )
231
225
dump_signal (sig_out , 'sig_out.f32' )
232
226
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
240
234
self .frame_size = self .subframe_size * self .nb_subframes
241
235
self .feature_dim = feature_dim
242
236
self .cond_size = cond_size
243
- self .has_gain = has_gain
244
- self .passthrough_size = passthrough_size
245
237
246
238
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 )
248
240
249
241
def forward (self , features , period , nb_frames , pre = None , states = None ):
250
242
device = features .device
@@ -266,7 +258,6 @@ def forward(self, features, period, nb_frames, pre=None, states=None):
266
258
267
259
sig = torch .zeros ((batch_size , 0 ), device = device )
268
260
cond = self .cond_net (features , period )
269
- passthrough = torch .zeros (batch_size , self .passthrough_size , device = device )
270
261
if pre is not None :
271
262
prev [:,:] = pre [:, self .frame_size - self .subframe_size : self .frame_size ]
272
263
exc_mem [:,- self .frame_size :] = pre [:, :self .frame_size ]
0 commit comments