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

Method decode_frames

moss_tts_realtime/app.py:211–229  ·  view source on GitHub ↗
(self, audio_frames: list[torch.Tensor])

Source from the content-addressed store, hash-verified

209 self.audio_eos_token = audio_eos_token
210
211 def decode_frames(self, audio_frames: list[torch.Tensor]) -> Iterator[np.ndarray]:
212 for frame in audio_frames:
213 tokens = frame
214 if tokens.dim() == 3:
215 tokens = tokens[0]
216 if tokens.dim() != 2:
217 raise ValueError(f"Expected [T, C] audio tokens, got {tuple(tokens.shape)}")
218 tokens, stop = _sanitize_tokens(tokens, self.codebook_size, self.audio_eos_token)
219 if tokens.numel() == 0:
220 if stop:
221 break
222 continue
223 self.decoder.push_tokens(tokens.detach())
224 for wav in self.decoder.audio_chunks():
225 if wav.numel() == 0:
226 continue
227 yield wav.detach().cpu().numpy().reshape(-1)
228 if stop:
229 break
230
231 def flush(self) -> Iterator[np.ndarray]:
232 final_chunk = self.decoder.flush()

Callers 2

run_streamMethod · 0.45
_runMethod · 0.45

Calls 3

push_tokensMethod · 0.80
audio_chunksMethod · 0.80
_sanitize_tokensFunction · 0.70

Tested by

no test coverage detected