Comfy-Org/ComfyUI · error · ValueError
The prompt references @Audio{idx}, but only voices 1..{len(v
Error message
The prompt references @Audio{idx}, but only voices 1..{len(voices)} exist. What it means
Grok @AudioN tag resolution failure where the index is entirely out of range: idx exceeds the number of voice slots (len(voices)), so no voice_{idx} exists at all. Distinct from the 'none' case — here the slot itself is missing. Raised inside the regex substitution loop, before any API call is made.
Source
Thrown at comfy_api_nodes/nodes_grok.py:119
audio_indices: dict[int, int] = {}
for slot, voice in enumerate(voices, start=1):
if voice != "none":
audio_indices[slot] = len(audio_indices)
def repl(match: re.Match) -> str:
kind = match.group(1).lower()
idx = int(match.group("idx") or 1)
if kind == "image":
if not 1 <= idx <= total_images:
raise ValueError(
f"The prompt references @Image{idx}, but only {total_images} "
f"reference images are connected (a batched input counts once per image)."
)
return f"<IMAGE_{idx - 1}>"
if idx not in audio_indices:
if 1 <= idx <= len(voices):
raise ValueError(f"The prompt references @Audio{idx}, but 'voice_{idx}' is set to 'none'.")
raise ValueError(f"The prompt references @Audio{idx}, but only voices 1..{len(voices)} exist.")
return f"<AUDIO_{audio_indices[idx]}>"
prev = None
while prev != prompt:
prev = prompt
prompt = _GROK_REF_TAG_RE.sub(repl, prompt)
return prompt
def _extract_grok_price(response) -> float | None:
if response.usage and response.usage.cost_in_usd_ticks is not None:
return response.usage.cost_in_usd_ticks / 10_000_000_000
return None
def _extract_grok_video_price(response) -> float | None:
price = _extract_grok_price(response)
if price is not None:View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Change the tag to a valid slot: @Audio1..@Audio{len(voices)}.
- Add the missing voice input(s) to the node so the index exists.
- Remove the tag if that voice is no longer used.
Example fix
# before: 3 voice slots prompt = "@Audio4 sings the chorus" # raises # after prompt = "@Audio3 sings the chorus"
Defensive patterns
Strategy: validation
Validate before calling
refs = {int(m.group("idx") or 1) for m in _TAG.finditer(prompt) if m.group(1).lower() == "audio"}
out_of_range = [i for i in refs if i > len(voices)]
assert not out_of_range, f"tags exceed {len(voices)} voice slots: {out_of_range}" Prevention
- Check every @AudioN tag against the current number of voice slots.
- Re-audit prompts after deleting voice inputs.
- Note bare '@Audio' defaults to index 1 and fails when no voices exist.
When it happens
Trigger: Prompt contains e.g. '@Audio4' while only 3 voice inputs exist (voices list length 3), or '@Audio' with zero voices configured (idx defaults to 1, and 1 <= idx <= 0 is impossible).
Common situations: Prompt templates written for more voice slots than the node version exposes; deleting voice inputs after writing the prompt; typo like '@Audio7' instead of '@Audio1'; assuming default-voice tagging works with no voices connected.
Related errors
- The prompt references @Audio{idx}, but 'voice_{idx}' is set
- The prompt references @Image{idx}, but only {total_images} r
- The pro model supports only 1 input image.
- A maximum of 3 input images is supported.
- Custom aspect ratio is only allowed when multiple images are
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/044a5182aea95e01.
Report an issue: GitHub.