(self, audio_data)
| 259 | |
| 260 | @T.no_grad() |
| 261 | def tokenize(self, audio_data): |
| 262 | orig_audio_shape = audio_data.shape |
| 263 | if exists(self.audio_cache): |
| 264 | audio_data = T.cat([self.audio_cache, audio_data], dim=-1) |
| 265 | self.audio_cache = audio_data[..., -(6*16_000):] |
| 266 | elif self.use_audio_cache: |
| 267 | self.audio_cache = audio_data[..., -(6*16_000):] |
| 268 | |
| 269 | if audio_data.shape[1] == 2: |
| 270 | enc_ch1 = self.audio_tokenizer.latent_from_data(audio_data[:, 0:1]) |
| 271 | enc_ch2 = self.audio_tokenizer.latent_from_data(audio_data[:, 1:2]) |
| 272 | return T.cat([enc_ch1, enc_ch2], dim=-1)[:, -(orig_audio_shape[-1]//2000):] |
| 273 | else: |
| 274 | return self.audio_tokenizer.latent_from_data(audio_data)[:, -(orig_audio_shape[-1]//2000):] |
| 275 | |
| 276 | @T.no_grad() |
| 277 | def untokenize(self, token_data): |
no test coverage detected