XB-BOX - ✂️ CosyVoice3 音频裁剪
Trim a reference clip by wall-clock time, not samples
- audio
- audio
CosyVoice voice cloning is picky about its reference audio: the model family wants clean, reasonably short samples (the XB nodes cap references around 30 seconds and recommend 3–10s), and the quality of that clip decides how good your clone sounds. So the first step of any CosyVoice workflow is usually "trim this recording down to the good 8 seconds." XB_CosyVoice3_AudioCrop is the boring, reliable node for exactly that - you give it an AUDIO input and MM:SS start/end times, and it hands back the cropped audio.
It's part of XB_ToolBox's bundled CosyVoice3 suite, a set of TTS nodes that wrap Fun-CosyVoice3 with zero-shot cloning, cross-lingual synthesis, and dialog generation. This crop node is the humble utility every other node in the family expects you to use upstream.
How it works
The node parses your time strings - it accepts MM:SS (e.g. 1:05) or HH:MM:SS - converts them to sample indices using the input audio's sample rate, clamps them to the file's actual length, and slices the waveform. That's the whole mechanism. The reason it exists rather than a generic audio trimmer: it's typed to the exact AUDIO dict format (waveform + sample_rate) the CosyVoice nodes produce and consume, so it slots straight into the chain with no conversion nodes.
The inputs that matter
- audio - any
AUDIOtensor, typically from a Load Audio node or another CosyVoice node's output. - start_time - string, default
0:00. FormatMM:SSorHH:MM:SS. - end_time - string, default
0:10.
Output: audio - the cropped AUDIO.
Installing
It ships inside XB_ToolBox's CosyVoice3 module, so install the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
then restart. The heavy part: the CosyVoice3 nodes need the pack's big dependency list - transformers, librosa, soundfile, modelscope, omegaconf, conformer, x-transformers, diffusers, pyworld and more, all in requirements.txt. pip install -r requirements.txt (or let ComfyUI Manager's dependency installer handle it). This is the single most common place installs go wrong - the transformers version can fight ComfyUI's own.
Common issues
- Cropped wrong section - time strings are absolute positions in the source file, not offsets.
0:10–0:18is the ten-to-eighteen-second region. - Parse errors with odd formats - stick to
MM:SS; a plain number like10isn't accepted. - Clone sounds bad after cropping - the crop is sample-accurate, so this is a reference choice problem, not a crop problem: pick a clip with steady, clean voice and no background music (the 3–10s sweet spot).
This is the "do the boring prep correctly" node - nothing glamorous, but the 8-second reference you cut with it is what every downstream CosyVoice clone in your workflow will be judged by.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| start_time | STRING | 0:00 | — |
| end_time | STRING | 0:10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| audio | AUDIO | — |