mstar.model.omnivoice.components.codec

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

decode_canvas(codec, tokens)

[C, T_tok] tokens -> 1-D waveform at codec.config.sample_rate.

encode_reference(codec, waveform)

[1, T] waveform at the codec's rate -> [C, T_tok] tokens.

load_codec(model_path[, cache_dir])

Load the codec from the checkpoint's subfolder, else the mirror.

post_process(waveform, config, ref_rms, ...)

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 waveform at codec.config.sample_rate.

Parameters:
Return type:

ndarray

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.

Parameters:
Return type:

Tensor

mstar.model.omnivoice.components.codec.load_codec(model_path, cache_dir=None)[source]#

Load the codec from the checkpoint’s subfolder, else the mirror.

Parameters:
  • model_path (str)

  • cache_dir (str | None)

Return type:

Module

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.

Imported from the omnivoice package rather than re-ported: the silence trim is pydub-based and re-implementing it would drift from the reference for no gain.

Parameters:
Return type:

ndarray