Nodes/XB_ToolBox/XB-BOX - 💾 CosyVoice3 保存说话人
ComfyUI Node

XB-BOX - 💾 CosyVoice3 保存说话人

Turn a voice clip into a reusable .pt speaker file, once

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - 💾 CosyVoice3 保存说话人
  • model
  • reference_audio
  • saved_path
reference_text
speaker_namemy_speaker

If you've ever rebuilt a voice-cloning workflow from scratch just because you lost the source audio, this node is the fix. It extracts the speaker embedding from a reference clip once and saves it to disk as a .pt file, so every future synthesis just loads the saved voice - no re-uploading audio, no re-running Whisper, no remembering which clip you used three weeks ago.

It's the bookkeeping half of the XB_ToolBox CosyVoice3 suite, and it pairs with the two preset-driven synthesis nodes (SpeakerClone and SpeakerInstruct2). Zero-shot cloning (via the ZeroShot node) is great for one-offs; this is what you use when a voice is going to show up in workflow after workflow.

How it works

The node takes your model from the ModelLoader, your reference_audio, an optional reference_text, and a speaker_name. Under the hood it calls CosyVoice's official frontend_zero_shot - the exact same feature-extraction path the model's own add_zero_shot_spk method uses - so you're getting the same speaker representation the reference implementation produces, not a hack.

If reference_text is empty, it auto-transcribes the clip with Whisper first, then formats the transcript with the You are a helpful assistant.<|endofprompt|> prefix CosyVoice3 needs. The extracted features get saved into ComfyUI/models/cosyvoice/speaker/<speaker_name>.pt as a spk2info-compatible dict. That file format matters: it's the same one CosyVoice itself uses for speaker presets, so the file is portable and understood by the standard tooling.

The node is an output node (it has no AUDIO output to chain), and its only output is saved_path - a STRING pointing at the .pt file, which you can use to confirm where it landed or pass to a display node.

The inputs that matter

  • model - from the CosyVoice3 ModelLoader. Same version you'll use for synthesis.
  • reference_audio - the voice to capture. 3–10 seconds, clean, single speaker. Garbage in, garbage out - this file is the whole identity of the voice.
  • reference_text - optional. Leave blank and Whisper transcribes it for you. If the clip is noisy, typing the transcript yourself will give a better embedding than Whisper's guess.
  • speaker_name - the name that becomes both the filename and the speaker ID inside the file. No extension. Call it something you'll recognize in a dropdown later.

Install and gotchas

Same pack, same install: ComfyUI Manager → search XB_ToolBox, or git clone https://github.com/wjluoxiao/XB_ToolBox.git into custom_nodes and restart. The CosyVoice dependency stack applies here too - openai-whisper is what does the auto-transcription, and it needs to be present or you'll just get an empty transcript.

The gotchas are mostly about the audio. If the reference clip is long, the node doesn't trim it for you - it uses the whole thing (up to the 30-second sanity check), so crop to the segment that best represents the voice before you save. And there's no overwrite warning: saving with an existing speaker name silently replaces the file. Keep that in mind when you're iterating on a voice and wonder why the synthesis didn't change - the old preset is probably still loaded in the graph.

One more thing worth knowing: the file lives in models/cosyvoice/speaker/, so it's part of your ComfyUI models folder and gets picked up by ComfyUI Manager's model browsing. Move machines? Copy the folder and your voices come with you.

Category🔊XB CosyVoice3/Utilities

Inputs (4)

NameTypeDefaultDescription
modelCOSYVOICE_MODEL
reference_audioAUDIO
reference_textSTRING
speaker_nameSTRINGmy_speaker

Outputs (1)

NameTypeDescription
saved_pathSTRING