mstar.model.nemotron_duplex.components.audio_codec#
EarTTS RVQ audio codec (tts_model.audio_codec.*).
A DAC/Vocos-style ConvNeXt codec: a downsampling encoder and an upsampling
decoder, each a heterogeneous stack of strided resample convs and ConvNeXt
blocks, plus a projected-RVQ quantizer (prvq).
- Channel schedule (from the checkpoint):
encoder: 18 ->[384]x3 ->768 ->[768]x3 ->1536 ->[1536]x3 ->512(latent) decoder: 512 ->1536 ->[1536]x3 ->768 ->[768]x3 ->384 ->[384]x3 ->18
Forward is a faithful port of NeMo RVQVAEModel / Wav2Latent /
Latent2Wav / PreTrainedProbabilisticVQ
(nemo/collections/speechlm2/modules/ear_tts_vae_codec.py, branch
nemotron-labs-voicechat). Config (from the checkpoint codec_config):
n_fft=16 hop_length=4 base_hidden_size=384 channel_mult=(1,2,4)
rates=(7,7,9) num_blocks=3 kernel_size=7 latent_size=512 codebook_size=1024
num_quantizers=31 wav_to_token_ratio=1764.
The encoder’s spectrogram/STFT and the decoder’s inverse-STFT overlap-add are ported verbatim. ConvNeXt blocks are causal (left-padded) and use a channel-dim LayerNorm with eps 1e-6.
Classes
|
|
|
Causal 1D ConvNeXt block (ports NeMo |
|
Projected residual vector quantizer (ports NeMo |
- class mstar.model.nemotron_duplex.components.audio_codec.AudioCodec(config=None)[source]#
Bases:
Module- Parameters:
config (CodecConfig | None)
- ae_decode(x, constrain_value_range=True)[source]#
Continuous latents
[B, T', latent]-> waveform[B, 1, T].
- decode(code, code_len=None, constrain_value_range=True)[source]#
Codes
[B, T', num_quantizers]-> (waveform[B, 1, T], wav_len).
- class mstar.model.nemotron_duplex.components.audio_codec.ConvNeXtBlock(dim, expand=4, kernel=7)[source]#
Bases:
ModuleCausal 1D ConvNeXt block (ports NeMo
ConvNeXt1d).Depthwise conv (left-padded for causality) -> channel-dim LayerNorm -> pointwise expand -> GELU -> pointwise project, with a residual add.
- forward(x)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.nemotron_duplex.components.audio_codec.ProjectedRVQ(num_quantizers, codebook, dim)[source]#
Bases:
ModuleProjected residual vector quantizer (ports NeMo
PreTrainedProbabilisticVQ).Per-quantizer codebooks (
mus_list) and running variances (_variance_list).encodegreedily selects the nearest codebook entry per residual level;decodesums the selected embeddings.