{"record":{"id":"d40e72f4e38413d4","repo":"unslothai/unsloth","slug":"no-dac-code-tokens-c1-c2-found-in-generated-outp","errorCode":null,"errorMessage":"No DAC code tokens (c1/c2) found in generated output","messagePattern":"No DAC code tokens \\(c1/c2\\) found in generated output","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/audio_codecs.py","lineNumber":245,"sourceCode":"\n        wav_np = self._bicodec_tokenizer.detokenize(\n            global_ids.to(device),\n            semantic_ids.to(device),\n        )\n        sr = self._bicodec_tokenizer.config.get(\"sample_rate\", 16000)\n        return _numpy_to_wav_bytes(wav_np, sr), sr\n\n    def decode_dac(self, generated_text: str, device: str) -> Tuple[bytes, int]:\n        \"\"\"Decode DAC tokens (OuteTTS) from generated text.\n\n        Extracts c1_N and c2_N codec code tokens via regex.\n        Returns (wav_bytes, 24000).\n        \"\"\"\n        c1 = list(map(int, re.findall(r\"<\\|c1_(\\d+)\\|>\", generated_text)))\n        c2 = list(map(int, re.findall(r\"<\\|c2_(\\d+)\\|>\", generated_text)))\n\n        if not c1 or not c2:\n            raise ValueError(\"No DAC code tokens (c1/c2) found in generated output\")\n\n        t = min(len(c1), len(c2))\n        c1 = c1[:t]\n        c2 = c2[:t]\n\n        codes = torch.tensor([[c1, c2]], dtype = torch.int64).to(device)\n        with torch.no_grad():\n            audio = self._dac_audio_codec.decode(codes)\n\n        waveform = audio.squeeze().cpu().numpy()\n        return _numpy_to_wav_bytes(waveform, 24000), 24000\n\n    def decode(\n        self,\n        audio_type: str,\n        device: str,\n        token_ids: Optional[list] = None,\n        text: Optional[str] = None,","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/audio_codecs.py#L227-L263","documentation":"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.","triggerScenarios":"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.","commonSituations":"Missing or malformed OuteTTS speaker reference; quantized variant dropping special audio tokens; wrong chat template for the OuteTTS model; sampling params causing immediate EOS.","solutions":["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","Provide the correct speaker profile/prompt for OuteTTS and retry","Check tokenizer special-token registration for the c1/c2 families","Retry with adjusted sampling parameters to avoid immediate EOS"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import re\ndef has_dac_output(text: str) -> bool:\n    return bool(re.search(r\"<\\|c1_\\d+\\|>\", text)) and bool(re.search(r\"<\\|c2_\\d+\\|>\", text))","typeGuard":null,"tryCatchPattern":"try:\n    wav, sr = codec.decode_dac(generated_text, device)\nexcept ValueError as e:\n    if \"DAC code tokens\" in str(e):\n        regenerate()  # degenerate output is usually stochastic","preventionTips":["Always pass the OuteTTS speaker profile/prompt","Verify c1/c2 tokens are special tokens in the tokenizer","Log generated text on failure to distinguish template vs sampling problems"],"tags":["tts","audio","dac","outetts","decode"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}