Nodes/MOSS-TTS 1.5/MOSS-TTS Encode Tokens
ComfyUI Node

MOSS-TTS Encode Tokens

Encode a Voice Once Instead of On Every Single Run

By eehrich·Created 4 months ago·Updated 20 days ago· 3
MOSS-TTS Encode Tokens
  • moss_model
  • audio
  • tokens
  • frames

MOSS-TTS never hears your waveform. Before it clones a voice it turns the reference clip into audio codes - 12.5 of them per second - and then works entirely in that space. MOSS-TTS Voice Clone does that encode for you, quietly, on every run. This node does it once.

That matters more than it sounds. With a 30-second reference the encode is a couple of seconds you pay again on every queue. With a minute-plus narration reference it's several seconds, and according to the node's own description that pass does not parallelise across concurrent requests - generations overlap, encodes stack up behind each other. If you're driving ComfyUI over the API and cloning the same voice in every prompt, you're paying that tax forever. Encode once, hand the codes downstream, and every later run starts straight at generation.

What it actually does

Give it an audio clip and it runs that clip through the model's own codec. The clip is first resampled to the model's native rate and loudness-normalised by the same processor path the Voice Clone reference goes through - which is the whole point: the codes that come out are interchangeable with the ones Voice Clone would have made internally, byte for byte the same pipeline.

The output is a MOSS_TOKENS tensor shaped [frames, n_vq] at 12.5 frames per second, so one frame is 80 ms. A 15-second clip is roughly 188 frames. It's a single codec pass - no sampling, no seed, no randomness - and it's cheap compared to generation, but not free, and not parallel-friendly.

Because the codec is part of the model bundle, the codes only mean anything to the model that made them. The dropdown's default entry is labelled "(1.7B)" but is actually the ~4.5B-parameter Local-Transformer; the other entry is the 8B. Encode on one and try to generate on the other and you get an error, not a weird voice.

The two inputs

There are only two, and neither needs explaining to death:

  • moss_model - from MOSS-TTS Load Model. Required; there's no offline codec here, the vocoder ships inside the loaded bundle.
  • audio - the clip you want as a voice reference. Any ComfyUI AUDIO: Load Audio, another MOSS node's audio output, or something you just generated.

Outputs are tokens (MOSS_TOKENS) and frames (INT). Wire tokens into Voice Clone.reference_tokens, Voice Continue.prev_tokens, MOSS-TTS Concat Tokens, or MOSS-TTS Save Tokens - that last one is how the encode survives a ComfyUI restart. frames is just information; divide by 12.5 for seconds, which is genuinely useful when you're checking whether a reference clears the minimum length.

The two rules that produce gibberish

These are the ones that will cost you an evening. Neither raises an error - you get unusable audio that sounds like a language you don't speak.

Give it at least ~10 seconds of speech. Five seconds is not enough acoustic evidence for MOSS to lock onto a voice; 10–20 s is the sweet spot. This applies to codes exactly as it applies to audio, because the constraint is about the amount of speech, not the format.

If these codes become a Voice Continue prefix, previous_text must transcribe this clip exactly. Trim the clip and you must trim the transcript to the same point. Concat Tokens can't check that for you - it only sees codes. This is the single most common way people break a continuation chain.

Installing it

ComfyUI-Manager: search MOSS-TTS 1.5 (by enrico) and install. Other packs carry "MOSS-TTS" in the name too, so check the author. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/eehrich/ComfyUI-MOSS-TTS-1.5.git

Restart ComfyUI. There are no pip dependencies on purpose - the pack's pyproject.toml deliberately installs nothing, relying on the torch, torchaudio and transformers ComfyUI already ships. The download is the real cost: ~9 GB for the model plus ~8.5 GB for its audio tokenizer (the 8B is ~17 GB + ~7 GB). Point MOSS-TTS Load Model at your own ComfyUI/models/moss_tts folder and neither happens.

Troubleshooting

  • Codes look right, generation is garbled - the reference was too short, or a trimmed token window carried a full-length transcript. Listen to the prefix with MOSS-TTS Decode Tokens before blaming the encode.
  • tokenizer_path warning about sample rate - MOSS-Audio-Tokenizer-v2 is the 48 kHz partner of the default model, MOSS-Audio-Tokenizer the 24 kHz partner of the 8B. Pairing the wrong one would output noise, so the pack refuses to guess and downloads instead.
  • transformers 5.4.0 / 5.5.0 - loading the tokenizer dies with non-default argument 'sampling_rate' follows default argument. Upgrade in ComfyUI's own environment: python -m pip install -U "transformers>=5.5.1".
  • Loaded the 8B on transformers 4.x - module 'transformers.processing_utils' has no attribute 'MODALITY_TO_BASE_CLASS_MAPPING'. Same fix; the 8B needs 5.x, the Local-Transformer runs on either.

One reality check before you build this into a loop: encoding once saves time, not VRAM. A token reference costs about the same memory as the audio it encodes - roughly 1 GB per 20 seconds of reference - because MOSS keeps the whole prefix in memory while it generates. If you were hoping tokens would let you carry a two-minute reference on a 12 GB card, they won't.

CategoryMOSS TTS 1.5

Inputs (2)

NameTypeDefaultDescription
moss_modelMOSS_MODELModel bundle produced by MOSS-TTS Load Model.
audioAUDIOAudio to encode. Resampled to the model's native rate and loudness-normalised by the processor exactly as the Voice Clone reference path does, so the resulting codes are interchangeable with it. Two rules the clip itself has to satisfy, both of which produce GIBBERISH (not a weaker voice) when broken: give it at least ~10 s -- around 5 s is not enough acoustic evidence for MOSS to lock onto the voice; and if these codes later serve as a Voice Continue prefix, whatever text you pass as 'previous_text' must transcribe THIS clip exactly -- trim the audio and you must trim the transcript to the same point.

Outputs (2)

NameTypeDescription
tokensMOSS_TOKENSAudio codes, shape [frames, n_vq]. Wire into Voice Clone 'reference_tokens', Voice Continue 'prev_tokens', MOSS-TTS Concat Tokens or MOSS-TTS Save Tokens.
framesINTNumber of code frames. Divide by 12.5 for seconds.