MCPcopy
hub / github.com/OpenMOSS/MOSS-TTS / encode

Method encode

moss_tts_delay/llama_cpp/pipeline.py:104–118  ·  view source on GitHub ↗
(self, waveform, n_quantizers=N_QUANTIZERS)

Source from the content-addressed store, hash-verified

102
103 class _Enc:
104 def encode(self, waveform, n_quantizers=N_QUANTIZERS):
105 if waveform.ndim == 1:
106 waveform = waveform[np.newaxis, np.newaxis, :]
107 elif waveform.ndim == 2:
108 waveform = waveform[np.newaxis, :]
109 T = waveform.shape[-1]
110 padded = ((T + DOWNSAMPLE_RATE - 1) // DOWNSAMPLE_RATE) * DOWNSAMPLE_RATE
111 if padded != T:
112 waveform = np.concatenate(
113 [waveform, np.zeros((1, 1, padded - T), dtype=np.float32)], axis=-1,
114 )
115 waveform = waveform.astype(np.float32)
116 nq = np.array(n_quantizers, dtype=np.int64)
117 r = engine.run(outs, {ins[0]: waveform, ins[1]: nq})
118 return r[0][:, 0, :int(r[1][0])].T.astype(np.int64)
119
120 def close(self):
121 engine.close()

Callers 15

mainFunction · 0.45
_encode_audio_tokensMethod · 0.45
run_streamMethod · 0.45
_ensure_warmup_textMethod · 0.45
__init__Method · 0.45
make_ensembleMethod · 0.45
_encode_audio_tokensMethod · 0.45
_handle_start_turnMethod · 0.45
_handle_push_textMethod · 0.45
mainFunction · 0.45

Calls 1

runMethod · 0.80

Tested by

no test coverage detected