(self, audio_frames: list[torch.Tensor])
| 138 | self.callbacks.on_audio_stream_stop() |
| 139 | |
| 140 | def decode_frames(self, audio_frames: list[torch.Tensor]) -> Iterator[np.ndarray]: |
| 141 | for frame in audio_frames: |
| 142 | tokens = frame |
| 143 | if tokens.dim() == 3: |
| 144 | tokens = tokens[0] |
| 145 | if tokens.dim() != 2: |
| 146 | raise ValueError(f"Expected [T, C] audio tokens, got {tuple(tokens.shape)}") |
| 147 | tokens, _ = _sanitize_tokens(tokens, self.codebook_size, self.audio_eos_token) |
| 148 | if tokens.numel() == 0: |
| 149 | continue |
| 150 | self.decoder.push_tokens(tokens.detach()) |
| 151 | for wav in self.decoder.audio_chunks(): |
| 152 | if wav.numel() == 0: |
| 153 | continue |
| 154 | self._mark_started() |
| 155 | yield wav.detach().cpu().numpy().reshape(-1) |
| 156 | |
| 157 | def flush(self) -> Iterator[np.ndarray]: |
| 158 | final_chunk = self.decoder.flush() |
no test coverage detected