Nodes/Audio nodes/bark generate coarse (2)
ComfyUI Node

bark generate coarse (2)

Where the voice gets its shape

By gitmyloΒ·Created 2 years agoΒ·Updated about a year agoΒ· 12
bark generate coarse (2)
  • coarse_model
  • semantic_tokens
  • semantic_history
  • coarse_history
  • codebooks
β—„temperature0.70β–Ί
β—„top_k0β–Ί
β—„top_p0.00β–Ί
β—„max_coarse_history630β–Ί
β—„sliding_window_len60β–Ί
β—„use_kv_cachingβ€”β–Ί

Stage two. You've got semantic tokens - the words, decided. bark_generate_coarse ("bark generate coarse (2)") turns those into the first two EnCodec codebooks, which are the rough sonic skeleton: the pitch contour, the rhythm, the way the voice sounds. If semantic tokens are the script, coarse codebooks are the first draft of the performance. Still not listenable on their own, but now it's clearly audio-shaped.

How it works

The coarse model is another GPT-style transformer, but it predicts a flattened stream of tokens across two EnCodec codebooks at a coarser time resolution (75 Hz vs the semantic stage's ~50 Hz). It also gets a windowed treatment: rather than attending to the whole sequence forever, it slides through the semantic tokens in chunks (sliding_window_len) while keeping a bounded history (max_coarse_history) of what came before. That's the mechanism behind the two weirdly-named knobs below.

The inputs that matter

Required:

  • coarse_model - from bark_loader with the coarse dropdown set to large/small.
  • semantic_tokens - the output of bark_generate_semantic.
  • temperature (0.7), top_k / top_p (0 = off) - same sampling controls as the semantic stage; defaults are fine 90% of the time.
  • max_coarse_history (default 630) - how many past coarse tokens the model is allowed to look at. Bigger = more coherent but slower; the cap exists because the coarse stage can't attend to a full 1024-token window.
  • sliding_window_len (default 60) - how many tokens it generates per window pass. Tune down on low VRAM to shrink the working set.
  • use_kv_caching - same speed-vs-VRAM tradeoff as the semantic node.

Optional, and this is the voice-cloning hook:

  • semantic_history and coarse_history - the text and coarse outputs of load_speaker_npz. Feed both (they're a pair - the node uses them together to establish a speaker's prosody) and the generated audio continues in that voice instead of defaulting to one of Bark's stock voices.

The output, codebooks, is a 2-row EnCodec codebook array. It feeds bark_generate_fine. If you want to hear what the coarse stage alone sounds like, wire it into encodec_decode - it'll be a muffled, buzzy approximation. That's not a bug; that's the point.

Install & troubleshooting

Same pack, same two-line install (ComfyUI Manager, search "Audio nodes", or git clone https://github.com/gitmylo/ComfyUI-audio-nodes into custom_nodes and restart). First run downloads the coarse weights to models/bark/.

The failure mode people actually hit: you provide only coarse_history without semantic_history (or vice versa) and the model just ignores your speaker entirely, because the code only uses the history when both are supplied. It won't error - it'll silently give you a default voice. If your cloned voice isn't sticking, check that both history inputs are connected. The other common one is VRAM: this stage is where long prompts start to choke, and dropping sliding_window_len or enabling kv caching is the lever that keeps a long generation alive on an 8GB card.

CategoryπŸ”‰ AudioNodes/bark

Inputs (10)

NameTypeDefaultDescription
coarse_modelBarkCoarseModelβ€”
semantic_tokensBarkSemanticTokensβ€”
temperatureFLOAT0.700.01–2β€”
top_kINT00–10000β€”
top_pFLOAT0.000–1β€”
max_coarse_historyINT63060–630β€”
sliding_window_lenINT601–512β€”
use_kv_cachingBOOLEANβ€”
semantic_historyoptBarkSemanticTokensβ€”
coarse_historyoptEncodecCodeBooksβ€”

Outputs (1)

NameTypeDescription
codebooksEncodecCodeBooksβ€”