MCPcopy Index your code
hub / github.com/acids-ircam/RAVE / encode

Method encode

scripts/export.py:237–263  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

235
236 @torch.jit.export
237 def encode(self, x):
238 if self.stereo_mode:
239 if self.n_channels == 1:
240 x = x[:, 0].unsqueeze(0)
241 elif self.n_channels > 2:
242 raise RuntimeError("stereo mode is not available when n_channels > 2")
243
244 if self.is_using_adain:
245 self.update_adain()
246
247 if self.resampler is not None:
248 x = self.resampler.to_model_sampling_rate(x)
249
250 batch_size = x.shape[:-2]
251 if self.input_mode == "pqmf":
252 x = x.reshape(-1, 1, x.shape[-1])
253 x = self.pqmf(x)
254 x = x.reshape(batch_size + (-1, x.shape[-1]))
255 elif self.input_mode == "mel":
256 if self.spectrogram is not None:
257 x = self.spectrogram(x)[..., :-1]
258 x = torch.log1p(x).reshape(batch_size + (-1, x.shape[-1]))
259 else:
260 raise RuntimeError()
261 z = self.encoder(x)
262 z = self.post_process_latent(z)
263 return z
264
265 @torch.jit.export
266

Callers 9

__init__Method · 0.95
forwardMethod · 0.95
mainFunction · 0.45
mainFunction · 0.45
post_process_latentMethod · 0.45
__init__Method · 0.45
mainFunction · 0.45
process_audio_arrayFunction · 0.45
process_audio_fileFunction · 0.45

Calls 4

update_adainMethod · 0.95
post_process_latentMethod · 0.95
spectrogramMethod · 0.80

Tested by

no test coverage detected