unslothai/unsloth · error · RuntimeError

Model {self.active_model_name} is not an audio model

Error message

Model {self.active_model_name} is not an audio model

What it means

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.

Source

Thrown at studio/backend/core/inference/inference.py:2071

        min_p: float = 0.0,
        max_new_tokens: int = 2048,
        repetition_penalty: float = 1.0,
        use_adapter: Optional[Union[bool, str]] = None,
        cancel_event = None,
    ) -> Tuple[bytes, int]:
        """Generate audio from text for TTS models.
        Returns (wav_bytes, sample_rate). Blocking — full audio before return.
        """
        if not self.active_model_name:
            raise RuntimeError("No active model")

        model_info = self.models[self.active_model_name]
        audio_type = model_info.get("audio_type")
        model = model_info["model"]
        tokenizer = model_info.get("tokenizer")

        if not audio_type:
            raise RuntimeError(f"Model {self.active_model_name} is not an audio model")

        top_k = self._normalize_top_k(top_k)
        # Every codec below concatenates its prompt instead of templating it, so this
        # is the one choke point for all four (#7066).
        text = neutralize_tts_prompt_text(text, audio_type)

        if cancel_event is not None and cancel_event.is_set():
            raise RuntimeError("Audio generation cancelled")
        with self._generation_lock:
            if cancel_event is not None and cancel_event.is_set():
                raise RuntimeError("Audio generation cancelled")
            if use_adapter is not None:
                self._apply_adapter_state(use_adapter)
            stopping_criteria = self._cancel_stopping_criteria(cancel_event)

            if audio_type == "snac":
                result = self._generate_snac(
                    model,

View on GitHub (pinned to 203007d190)

Solutions

  1. Load the TTS model (orboyloo/universe-tts, orpheus, etc.) and make it active before audio calls
  2. If the engine supports one active model, orchestrate load→TTS→restore between chat and audio workloads
  3. Check the model's config identified it as audio at load time (audio_type populated)

Example fix

// before
engine.load_model("qwen2.5-7b")
engine.generate_audio("hello")
// after
engine.load_model("orpheus-3b")
engine.generate_audio("hello")
Defensive patterns

Strategy: validation

Validate before calling

info = engine.models.get(engine.active_model_name, {})
if not info.get("audio_type"):
    raise HTTPException(409, f"Active model '{engine.active_model_name}' is not a TTS model")

Type guard

def is_audio_model(engine) -> bool:
    return bool(engine.models.get(engine.active_model_name, {}).get("audio_type"))

Try / catch

try:
    engine.generate_audio(text)
except RuntimeError as e:
    if "is not an audio model" in str(e):
        load_tts_model_and_retry()
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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