microsoft/VibeVoice · error · RuntimeError

StreamingTTSService not initialized

Error message

StreamingTTSService not initialized

What it means

Raised by StreamingTTSService._prepare_inputs when self.processor or self.model is None, i.e. the method was called before service.load() finished assigning them. It is a guard against using the service in a half-constructed state, not a model error.

Source

Thrown at demo/web/app.py:184

                    map_location=self._torch_device,
                    weights_only=True,
                )
            self._voice_cache[key] = prefilled_outputs

        return self._voice_cache[key]

    def _get_voice_resources(self, requested_key: Optional[str]) -> Tuple[str, object, Path, str]:
        key = requested_key if requested_key and requested_key in self.voice_presets else self.default_voice_key
        if key is None:
            key = next(iter(self.voice_presets))
            self.default_voice_key = key

        prefilled_outputs = self._ensure_voice_cached(key)
        return key, prefilled_outputs

    def _prepare_inputs(self, text: str, prefilled_outputs: object):
        if not self.processor or not self.model:
            raise RuntimeError("StreamingTTSService not initialized")

        processor_kwargs = {
            "text": text.strip(),
            "cached_prompt": prefilled_outputs,
            "padding": True,
            "return_tensors": "pt",
            "return_attention_mask": True,
        }

        processed = self.processor.process_input_with_cached_prompt(**processor_kwargs)

        prepared = {
            key: value.to(self._torch_device) if hasattr(value, "to") else value
            for key, value in processed.items()
        }
        return prepared

    def _run_generation(

View on GitHub (pinned to 94da20d98b)

Solutions

  1. Call service.load() once before any inference (the app startup event does this).
  2. Make sure MODEL_PATH points to a valid model directory so load() does not fail partway.
  3. Gate the TTS endpoint behind a readiness flag set only after startup completes, returning 503 until then.
  4. In tests, always run load() (or mock both processor and model) before calling generate().

Example fix

# before
service = StreamingTTSService(model_path, device)
service._prepare_inputs(text, prefilled)  # RuntimeError

# after
service = StreamingTTSService(model_path, device)
service.load()
service._prepare_inputs(text, prefilled)
Defensive patterns

Strategy: type-guard

Validate before calling

def service_ready(service) -> bool:
    return service is not None and service.processor is not None and service.model is not None

Type guard

def is_loaded(service) -> bool:
    return getattr(service, "processor", None) is not None and getattr(service, "model", None) is not None

Try / catch

if not is_loaded(service):
    raise HTTPException(status_code=503, detail="TTS service warming up")
return service.generate(...)

Prevention

When it happens

Trigger: Instantiating StreamingTTSService(model_path=..., device=...) and calling generate/prepare before .load(); load() failed partway (e.g. MODEL_PATH invalid) leaving attributes unset; a request reaching the handler before the startup event completed.

Common situations: Race in FastAPI: a request hits the TTS endpoint while the startup hook is still loading weights; an exception during load() was swallowed and the half-initialized service kept in app.state; unit tests constructing the service without load().

Related errors


AI-assisted analysis of microsoft/VibeVoice@94da20d98b (2026-08-15). Data as JSON: /api/errors/3e234b59e89ff9f1. Report an issue: GitHub.