MCPcopy Create free account
hub / github.com/OpenMOSS/MOSS-TTS / decode_frames

Method decode_frames

moss_tts_realtime/fast_api.py:140–155  ·  view source on GitHub ↗
(self, audio_frames: list[torch.Tensor])

Source from the content-addressed store, hash-verified

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()

Callers 3

_handle_start_turnMethod · 0.95
_handle_push_textMethod · 0.45
_handle_finish_turnMethod · 0.45

Calls 4

_mark_startedMethod · 0.95
push_tokensMethod · 0.80
audio_chunksMethod · 0.80
_sanitize_tokensFunction · 0.70

Tested by

no test coverage detected