mudler/LocalAI · error · Exception
Model not loaded. Call LoadModel first.
Error message
Model not loaded. Call LoadModel first.
What it means
Raised inside AudioTranscription of the moonshine backend when a transcription request arrives before any successful LoadModel call has set self.transcriber. It is a plain Exception (not a typed error) raised deliberately to be caught by the surrounding try block and returned as a failed gRPC Result.
Source
Thrown at backend/python/moonshine/backend.py:88
model_arch = self.options["model_arch"]
# Get the model path and architecture
model_path, model_arch = get_model_for_language(language, model_arch)
print(f"Loading model: {model_path} with architecture: {model_arch} for language: {language}", file=sys.stderr)
# Initialize the transcriber
self.transcriber = Transcriber(model_path=model_path, model_arch=model_arch)
print("Model loaded successfully", file=sys.stderr)
except Exception as err:
return backend_pb2.Result(success=False, message=f"Unexpected {err=}, {type(err)=}")
return backend_pb2.Result(message="Model loaded successfully", success=True)
def AudioTranscription(self, request, context):
resultSegments = []
text = ""
try:
if self.transcriber is None:
raise Exception("Model not loaded. Call LoadModel first.")
# Load the audio file
audio_data, sample_rate = load_wav_file(request.dst)
print(f"Loaded audio file: {request.dst} with sample rate: {sample_rate}", file=sys.stderr)
# Transcribe without streaming
transcript = self.transcriber.transcribe_without_streaming(
audio_data, sample_rate=sample_rate, flags=0
)
# Process transcript lines
full_text_parts = []
for idx, line in enumerate(transcript.lines):
line_text = line.text.strip()
full_text_parts.append(line_text)
# Create segment with timing information
start_ms = int(line.start_time * 1000)View on GitHub (pinned to 44413a9d06)
Solutions
- Call LoadModel with a valid model_path/model_arch and confirm success=true before transcribing
- Check the LoadModel Result message — a prior failure like a missing model file leaves transcriber None
- Verify the model directory exists and the moonshine model arch string is correct, then retry the load
Example fix
# before stub.AudioTranscription(req) # 'Model not loaded. Call LoadModel first.' # after res = stub.LoadModel(load_req) assert res.success, res.message stub.AudioTranscription(req)
Defensive patterns
Strategy: try-catch
Validate before calling
# gRPC clients: ensure LoadModel succeeded first
load_resp = stub.LoadModel(backend_pb2.ModelOptions(model=model_path))
if not load_resp.success:
raise RuntimeError(f'LoadModel failed: {load_resp.message}')
# only now transcribe Type guard
def backend_ready(servicer) -> bool:
return servicer.transcriber is not None Try / catch
try:
result = stub.AudioTranscription(req)
except grpc.RpcError as err:
if 'Model not loaded' in (err.details() or ''):
load_and_retry() # explicit recovery, not silent fallback
else:
raise Prevention
- Gate transcription on LoadModel success in orchestration code
- Treat failed loads as fatal, not skippable
- Add a readiness/health signal that reflects loaded state
When it happens
Trigger: Calling the AudioTranscription RPC on a fresh backend instance that never loaded a model, or after a LoadModel that failed (e.g. bad model path/arch) leaving self.transcriber as None.
Common situations: Startup ordering issues where the client sends transcription before load completes, failed loads being ignored by orchestration code, or health checks not distinguishing loaded vs unloaded state.
Related errors
- audio is required for LongCat-Video-Avatar-1.5
- audio input is not a readable staged file
- Model not loaded
- dataset_source is required (path to a preprocessed dataset)
- start_image is not a readable staged file
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/c9a7a0d437466f6f.
Report an issue: GitHub.