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

Method encode

moss_tts_delay/llama_cpp/pipeline.py:836–846  ·  view source on GitHub ↗
(self, waveform: np.ndarray)

Source from the content-addressed store, hash-verified

834 self._device = device
835
836 def encode(self, waveform: np.ndarray) -> np.ndarray:
837 import torch
838 if waveform.ndim == 1:
839 waveform = waveform[np.newaxis, np.newaxis, :]
840 elif waveform.ndim == 2:
841 waveform = waveform[np.newaxis, :]
842 wav_t = torch.from_numpy(waveform).to(self._device)
843 codes = self._model.encode(wav_t)
844 if isinstance(codes, tuple):
845 codes = codes[0]
846 return codes.cpu().numpy().squeeze().T.astype(np.int64)
847
848 def decode(self, audio_codes: np.ndarray) -> np.ndarray:
849 import torch

Callers

nothing calls this directly

Calls 2

toMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected