Nodes/Audio nodes/bark generate semantic (1)
ComfyUI Node

bark generate semantic (1)

The stage that decides what gets said

By gitmyloΒ·Created 2 years agoΒ·Updated about a year agoΒ· 12
bark generate semantic (1)
  • text_model
  • encoded_prompt
  • semantic tokens
β—„temperature0.70β–Ί
β—„top_k0β–Ί
β—„top_p0.00β–Ί
β—„min_eos_p0.20β–Ί
β—„allow_early_stoptrueβ–Ί
β—„max_gen_duration_s0.00β–Ί
β—„use_kv_cachingβ€”β–Ί

Bark generates speech in three stages, and the "(1)" in this node's name is doing real work: this is stage one, the semantic stage. bark_generate_semantic takes the token array from bark_text_encode and samples the semantic tokens - the layer where the model has decided what words to say and roughly how. It doesn't sound like anything yet. It's the script, not the performance.

How it works

The text model you loaded in bark_loader is a GPT-style transformer that predicts Bark's semantic vocabulary (10,000 tokens) one token at a time, at a fixed rate of 49.9 tokens per second. It runs for up to 768 steps - which works out to about 15 seconds of audio - and stops early when it hits the end-of-speech token or decides it's done. Everything you tune in this node is tuning how that token-by-token sampling behaves.

The inputs that matter

  • text_model - from bark_loader (text set to large or small).
  • encoded_prompt - the output of bark_text_encode. This is non-negotiable; the node expects the exact padded shape that encoder produces.

Then the sampler knobs, which you'll recognize if you've ever touched a diffusion sampler:

  • temperature (default 0.7) - higher = more chaotic delivery, lower = flatter and more stable. 0.7 is a good default; drop toward 0.4 if you're getting repeated or jumbled words.
  • top_k and top_p (both default 0 = disabled) - classic nucleus/frequency filters. Leave them at 0 unless you're fighting degenerate output.
  • min_eos_p (0.2) and allow_early_stop - control when the model is allowed to decide "sentence's over" and end. min_eos_p is a probability threshold on the end token; raise it to force longer, less eager-to-stop speech.
  • max_gen_duration_s (default 0 = no cap, max 15) - hard ceiling on how much audio it'll generate before giving up.
  • use_kv_caching - caches key/value states between steps instead of recomputing the whole context every token. Faster, and the reason this node can keep up at all. Leave it on if you have the VRAM; it's off in the shipped example workflow.

The single output, semantic tokens (BarkSemanticTokens), feeds bark_generate_coarse. You can also wire it into the semantic_history input of bark_text_encode to continue a conversation in the same style.

Install & the shared gotchas

It's in gitmylo/ComfyUI-audio-nodes - grab the pack via ComfyUI Manager (search "Audio nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/gitmylo/ComfyUI-audio-nodes

restart, and remember the whole pipeline needs the model weights downloaded on first run.

The pitfall most people hit: this stage is where gibberish gets born. If your output sounds like a word salad, it's almost always the semantic stage's sampling, not the later stages - fix temperature/min_eos_p here before touching the fine stage. And if you crank max_gen_duration_s and hear it cut off mid-sentence, that's exactly what you asked for: the cap is a hard stop, not a soft one. This node also has no seed input, so identical settings will produce different takes every run - that's the point, but if you want a specific take, you'll need to save the semantic tokens and reuse them.

CategoryπŸ”‰ AudioNodes/bark

Inputs (9)

NameTypeDefaultDescription
text_modelBarkTextModelβ€”
encoded_promptBarkTextEncodingsβ€”
temperatureFLOAT0.700.01–2β€”
top_kINT00–10000β€”
top_pFLOAT0.000–1β€”
min_eos_pFLOAT0.200–1β€”
allow_early_stopBOOLEANtrueβ€”
max_gen_duration_sFLOAT0.000–15β€”
use_kv_cachingBOOLEANβ€”

Outputs (1)

NameTypeDescription
semantic tokensBarkSemanticTokensβ€”