Args: tokens: (B=1, nq, L) Returns: audio: (B=1, t)
(self, tokens: torch.Tensor)
| 306 | |
| 307 | @torch.inference_mode() |
| 308 | def decode(self, tokens: torch.Tensor): |
| 309 | """ |
| 310 | Args: |
| 311 | tokens: (B=1, nq, L) |
| 312 | Returns: |
| 313 | audio: (B=1, t) |
| 314 | """ |
| 315 | tokens = tokens.permute(1, 0, 2) # (B, nq, L) -> (nq, B, L) |
| 316 | vq_out_feats = self.rvq.decode_codes(tokens) |
| 317 | vq_out_feats = vq_out_feats.transpose(1, 2) |
| 318 | vq_out_length = torch.tensor( |
| 319 | [vq_out_feats.shape[1]], dtype=torch.long, device=vq_out_feats.device |
| 320 | ) |
| 321 | vq_out_feats, vq_out_length = self.upsample(vq_out_feats, vq_out_length) |
| 322 | # audio: (b, t) |
| 323 | audio, audio_length = self.acoustic_decoder(vq_out_feats, vq_out_length) |
| 324 | return audio |
| 325 | |
| 326 | @torch.inference_mode() |
| 327 | def decode_one_token( |
no test coverage detected