Nodes/CosyVoice2 for ComfyUI/NTCosyVoiceZeroShotSampler
ComfyUI Node

NTCosyVoiceZeroShotSampler

Clone a Voice From One Short Clip — CosyVoice2 Zero-Shot in ComfyUI

By muxueChen·Created 2 years ago·Updated about a year ago· 170
NTCosyVoiceZeroShotSampler
  • audio
  • tts_speech
speed1.0
text
prompt_text

You want a voice cloned in ComfyUI - not another cloud API with a key and a meter running. NTCosyVoiceZeroShotSampler is the node for that. It runs Alibaba's CosyVoice2-0.5B entirely on your machine. Give it a few seconds of someone talking, type the line you want said, and it reads it back in their voice. Zero-shot means exactly that: no training run, no fine-tune, no speaker ID. One clean reference clip is the whole setup.

This node deserves context, because it fills a real hole. ComfyUI became the default for image and video generation largely on the strength of its custom-node ecosystem, but audio was the quiet corner for a long time. The few CosyVoice nodes floating around were written against CosyVoice1 and quietly went stale; CosyVoice2 - FunAudioLLM's rebuilt model with much better naturalness - had essentially no ComfyUI support until this pack showed up. So this isn't a vanity node; it's one of the few ways to run a current CosyVoice in the graph at all.

How it works

The node is a thin wrapper around the CosyVoice2 class vendored into the pack. It loads the model from pretrained_models/CosyVoice2-0.5B on your first inference - lazily, so ComfyUI startup stays fast - with JIT acceleration on and ONNX/TensorRT off. Your reference audio gets squashed to mono and resampled to 16 kHz, which is where CosyVoice does its speech-token work. Then inference_zero_shot takes over: the model pulls a speaker embedding out of your clip, and an LLM-conditioned flow model (with a HiFiT vocoder at the end) renders your text in that timbre. The output comes back as an AUDIO dict at the model's native 22.05 kHz.

The inputs that matter

There are only four, and you really set three:

  • audio - the reference clip. 5–10 seconds of clean, single-speaker speech beats a longer noisy recording every time.
  • prompt_text - the transcript of that clip. This is the one beginners skip, and it's the difference between "close" and "uncanny."
  • text - the line you actually want spoken.
  • speed - 0.5–1.5, default 1.0. Leave it alone unless the delivery is dragging.

There's a single output, tts_speech (AUDIO). Wire it into the built-in PreviewAudio node, or a SaveAudio/VideoHelperSuite node to write it to disk.

Installing it

It comes with the whole ComfyUI_NTCosyVoice pack, so install the pack once and you get all three samplers. ComfyUI Manager can find it by searching "CosyVoice," or do it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/muxueChen/ComfyUI_NTCosyVoice
cd ComfyUI_NTCosyVoice
pip install -r requirements.txt
python downloadmodel.py

Then restart ComfyUI. Two things to flag before you start: requirements.txt is heavy - deepspeed, TensorRT, onnxruntime-gpu, lightning - so expect a long install and consider a dedicated venv. And the model doesn't come with the pack: downloadmodel.py pulls CosyVoice2-0.5B from ModelScope into pretrained_models/, and that download can take a while. The ttsfrd step in the README is optional; without it the node falls back to WeTextProcessing for text normalization.

Troubleshooting

  • Red "undefined" nodes right after install. The dependency list is where installs die. If Manager's "Try to Fix" button fails, this is almost always a missing package - check the pack's install log, not your GPU.
  • Model file errors on first run. You skipped downloadmodel.py, or it didn't finish. Run it from inside the pack folder and let it complete.
  • Reference clip below 16 kHz. The node asserts the input sample rate is above 16 kHz and will throw if it isn't. Upsample your clip first.
  • First generation is slow. That's JIT compile plus a one-time model load. Later runs are fine; expect roughly 1.2–1.4× realtime on a decent GPU, and the model fits in ~4–6 GB VRAM.
  • The clone sounds off. Fix the transcript first. A mismatched prompt_text will drag the whole result down, and no speed slider fixes that.
CategoryNineton Nodes

Inputs (4)

NameTypeDefaultDescription
audioAUDIO
speedFLOAT1.00.5–1.5
textSTRING
prompt_textSTRING

Outputs (1)

NameTypeDescription
tts_speechAUDIO