mstar.model.cosyvoice3.components.onnx_weights#

Weights of the ONNX-only front-end models, loaded into PyTorch modules.

CosyVoice3 ships its speech tokenizer (speech_tokenizer_v3.onnx) and its speaker encoder (campplus.onnx) as ONNX graphs only. Both are architectures Chatterbox already implements: the tokenizer is S3Tokenizer with twelve blocks, the speaker encoder is CAMPPlus. The exporter renamed most weights (onnx::MatMul_3998), so they are matched by the order the graph uses them against the order the PyTorch module calls its layers, with every shape checked. CAMPPlus was exported with each batch norm that follows a convolution folded into it; such a convolution loads its folded weight and its batch norm becomes the identity plus the folded bias.

read_onnx decodes just the protobuf fields needed (node inputs and op types, initializers, Constant values, epsilon), so no onnx dependency is needed.

Functions

load_campplus(campplus, path[, feat_dim])

campplus.onnx -> Chatterbox's CAMPPlus; returns the number of convolutions and batch norms loaded.

load_speech_tokenizer(tokenizer, path)

speech_tokenizer_v3.onnx -> Chatterbox's S3Tokenizer; returns the number of tensors loaded.

read_onnx(path)

The nodes, initializers and constants of an ONNX model file.

Classes

OnnxGraph(nodes, tensors, initializers)

OnnxNode(op_type, inputs, outputs, floats)

class mstar.model.cosyvoice3.components.onnx_weights.OnnxGraph(nodes: 'list[OnnxNode]', tensors: 'dict[str, np.ndarray]', initializers: 'frozenset[str]')[source]#

Bases: object

Parameters:
initializers: frozenset[str]#
nodes: list[OnnxNode]#
tensors: dict[str, ndarray]#
class mstar.model.cosyvoice3.components.onnx_weights.OnnxNode(op_type: 'str', inputs: 'list[str]', outputs: 'list[str]', floats: 'dict[str, float]'=<factory>)[source]#

Bases: object

Parameters:
floats: dict[str, float]#
inputs: list[str]#
op_type: str#
outputs: list[str]#
mstar.model.cosyvoice3.components.onnx_weights.load_campplus(campplus, path, feat_dim=80)[source]#

campplus.onnx -> Chatterbox’s CAMPPlus; returns the number of convolutions and batch norms loaded.

Parameters:
Return type:

int

mstar.model.cosyvoice3.components.onnx_weights.load_speech_tokenizer(tokenizer, path)[source]#

speech_tokenizer_v3.onnx -> Chatterbox’s S3Tokenizer; returns the number of tensors loaded. Linear weights are stored transposed (MatMul).

Parameters:
Return type:

int

mstar.model.cosyvoice3.components.onnx_weights.read_onnx(path)[source]#

The nodes, initializers and constants of an ONNX model file.

Parameters:

path (str | Path)

Return type:

OnnxGraph