unslothai/unsloth · error · ValueError

No DAC code tokens (c1/c2) found in generated output

Error message

No DAC code tokens (c1/c2) found in generated output

What it means

Raised in decode_dac (OuteTTS path) when regex extraction of <|c1_N|> or <|c2_N|> DAC code tokens finds an empty list for either channel. The LLM output was supposed to interleave two DAC codebook streams as special-token text but emitted at least one channel with zero tokens, so no waveform can be reconstructed.

Source

Thrown at studio/backend/core/inference/audio_codecs.py:245

        wav_np = self._bicodec_tokenizer.detokenize(
            global_ids.to(device),
            semantic_ids.to(device),
        )
        sr = self._bicodec_tokenizer.config.get("sample_rate", 16000)
        return _numpy_to_wav_bytes(wav_np, sr), sr

    def decode_dac(self, generated_text: str, device: str) -> Tuple[bytes, int]:
        """Decode DAC tokens (OuteTTS) from generated text.

        Extracts c1_N and c2_N codec code tokens via regex.
        Returns (wav_bytes, 24000).
        """
        c1 = list(map(int, re.findall(r"<\|c1_(\d+)\|>", generated_text)))
        c2 = list(map(int, re.findall(r"<\|c2_(\d+)\|>", generated_text)))

        if not c1 or not c2:
            raise ValueError("No DAC code tokens (c1/c2) found in generated output")

        t = min(len(c1), len(c2))
        c1 = c1[:t]
        c2 = c2[:t]

        codes = torch.tensor([[c1, c2]], dtype = torch.int64).to(device)
        with torch.no_grad():
            audio = self._dac_audio_codec.decode(codes)

        waveform = audio.squeeze().cpu().numpy()
        return _numpy_to_wav_bytes(waveform, 24000), 24000

    def decode(
        self,
        audio_type: str,
        device: str,
        token_ids: Optional[list] = None,
        text: Optional[str] = None,

View on GitHub (pinned to 203007d190)

Solutions

  1. Log the first ~500 chars of generated text to verify whether any <|c1_|/<|c2_| tokens appear at all — plain text means a prompting/template issue
  2. Provide the correct speaker profile/prompt for OuteTTS and retry
  3. Check tokenizer special-token registration for the c1/c2 families
  4. Retry with adjusted sampling parameters to avoid immediate EOS
Defensive patterns

Strategy: fallback

Validate before calling

import re
def has_dac_output(text: str) -> bool:
    return bool(re.search(r"<\|c1_\d+\|>", text)) and bool(re.search(r"<\|c2_\d+\|>", text))

Try / catch

try:
    wav, sr = codec.decode_dac(generated_text, device)
except ValueError as e:
    if "DAC code tokens" in str(e):
        regenerate()  # degenerate output is usually stochastic

Prevention

When it happens

Trigger: Model emitted only c1 or only c2 tokens; generation ended before any audio tokens; OuteTTS prompt/prefix (speaker profile) missing so the model answered in plain text; tokenizer without the c1/c2 tokens registered as special so they never appear in decoded text.

Common situations: Missing or malformed OuteTTS speaker reference; quantized variant dropping special audio tokens; wrong chat template for the OuteTTS model; sampling params causing immediate EOS.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/d40e72f4e38413d4. Report an issue: GitHub.