mstar.model.omnivoice.components.codec#
Higgs-Audio-v2 codec wrappers: waveform <-> 8-row token canvas.
HiggsAudioV2TokenizerModel ships in transformers, so nothing is
re-implemented here — these are the two thin seams M* needs, plus the
post-processing the reference applies after decode.
The codec weights live in the OmniVoice checkpoint under audio_tokenizer/.
The standalone mirror is the fallback the reference falls back to, kept for
checkpoints published without the subfolder.
Functions
|
|
|
|
|
Load the codec from the checkpoint's subfolder, else the mirror. |
|
Silence trim, level match, fade and pad — the reference's tail. |
- mstar.model.omnivoice.components.codec.decode_canvas(codec, tokens)[source]#
[C, T_tok]tokens -> 1-D float32 waveform atcodec.config.sample_rate, on the codec’s device.Runs under the engine’s
no_grad, notinference_mode: the compiled acoustic decoder (code2wav’scompile_regions) was warmed on ordinary tensors, and an inference tensor fails its guards and recompiles it.
- mstar.model.omnivoice.components.codec.encode_reference(codec, waveform)[source]#
[1, T]waveform at the codec’s rate ->[C, T_tok]tokens.The tail is clipped to a whole number of hops first, as the reference does: a partial hop would encode to a frame the decoder cannot place.
- mstar.model.omnivoice.components.codec.load_codec(model_path, cache_dir=None)[source]#
Load the codec from the checkpoint’s subfolder, else the mirror.
- mstar.model.omnivoice.components.codec.post_process(waveform, config, ref_rms, pad_duration, fade_duration, enabled)[source]#
Silence trim, level match, fade and pad — the reference’s tail.
Level handling differs by mode and is not cosmetic: a cloned voice is matched to the reference’s RMS (quiet references stay quiet), while a designed or automatic voice has no reference to match and is peak-normalised to 0.5 instead.
The fade and pad are the
omnivoicepackage’s own; the silence trim is a sample-exact vectorized port of its pydub-based one (silence.py), which cost ~14 ms of Python per second of audio.- Parameters:
waveform (ndarray)
config (OmniVoiceConfig)
ref_rms (float | None)
pad_duration (float)
fade_duration (float)
enabled (bool)
- Return type:
ndarray