{"record":{"id":"1e1f2814a278b5be","repo":"unslothai/unsloth","slug":"model-self-active-model-name-is-not-an-audio-mod","errorCode":null,"errorMessage":"Model {self.active_model_name} is not an audio model","messagePattern":"Model (.+?) is not an audio model","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/inference.py","lineNumber":2071,"sourceCode":"        min_p: float = 0.0,\n        max_new_tokens: int = 2048,\n        repetition_penalty: float = 1.0,\n        use_adapter: Optional[Union[bool, str]] = None,\n        cancel_event = None,\n    ) -> Tuple[bytes, int]:\n        \"\"\"Generate audio from text for TTS models.\n        Returns (wav_bytes, sample_rate). Blocking — full audio before return.\n        \"\"\"\n        if not self.active_model_name:\n            raise RuntimeError(\"No active model\")\n\n        model_info = self.models[self.active_model_name]\n        audio_type = model_info.get(\"audio_type\")\n        model = model_info[\"model\"]\n        tokenizer = model_info.get(\"tokenizer\")\n\n        if not audio_type:\n            raise RuntimeError(f\"Model {self.active_model_name} is not an audio model\")\n\n        top_k = self._normalize_top_k(top_k)\n        # Every codec below concatenates its prompt instead of templating it, so this\n        # is the one choke point for all four (#7066).\n        text = neutralize_tts_prompt_text(text, audio_type)\n\n        if cancel_event is not None and cancel_event.is_set():\n            raise RuntimeError(\"Audio generation cancelled\")\n        with self._generation_lock:\n            if cancel_event is not None and cancel_event.is_set():\n                raise RuntimeError(\"Audio generation cancelled\")\n            if use_adapter is not None:\n                self._apply_adapter_state(use_adapter)\n            stopping_criteria = self._cancel_stopping_criteria(cancel_event)\n\n            if audio_type == \"snac\":\n                result = self._generate_snac(\n                    model,","sourceCodeStart":2053,"sourceCodeEnd":2089,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/inference.py#L2053-L2089","documentation":"generate_audio reads audio_type from the active model's registry entry; if it is unset the active model is not an audio/TTS model, and the routine raises RuntimeError('Model X is not an audio model'). This prevents dispatching an LLM or diffusion model into SNAC/codec-specific generation branches.","triggerScenarios":"Calling the audio-generation endpoint while an LLM (or any non-audio model) is the active model — e.g. after loading a chat model and then hitting the TTS endpoint without switching models.","commonSituations":"Single-active-model architecture where users forget to switch; a shared engine instance serving both chat and TTS clients; automation scripts assuming a TTS model is resident.","solutions":["Load the TTS model (orboyloo/universe-tts, orpheus, etc.) and make it active before audio calls","If the engine supports one active model, orchestrate load→TTS→restore between chat and audio workloads","Check the model's config identified it as audio at load time (audio_type populated)"],"exampleFix":"// before\nengine.load_model(\"qwen2.5-7b\")\nengine.generate_audio(\"hello\")\n// after\nengine.load_model(\"orpheus-3b\")\nengine.generate_audio(\"hello\")","handlingStrategy":"validation","validationCode":"info = engine.models.get(engine.active_model_name, {})\nif not info.get(\"audio_type\"):\n    raise HTTPException(409, f\"Active model '{engine.active_model_name}' is not a TTS model\")","typeGuard":"def is_audio_model(engine) -> bool:\n    return bool(engine.models.get(engine.active_model_name, {}).get(\"audio_type\"))","tryCatchPattern":"try:\n    engine.generate_audio(text)\nexcept RuntimeError as e:\n    if \"is not an audio model\" in str(e):\n        load_tts_model_and_retry()\n    raise","preventionTips":["Check audio_type on the active model before calling TTS endpoints","Don't assume the last loaded model is the right kind for the request","Surface model-type metadata in load responses so clients can route"],"tags":["tts","audio","state","model-mismatch"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}