fishaudio/fish-speech · critical · TypeError
Expected GenerateResponse, got {type(wrapped_result.response
Error message
Expected GenerateResponse, got {type(wrapped_result.response).__name__} What it means
InferenceEngine.inference wraps the underlying model's streaming responses and asserts each response is a GenerateResponse instance; any other type coming through the response channel is treated as a protocol violation between the engine layers and raises a TypeError.
Source
Thrown at fish_speech/inference_engine/__init__.py:103
while True:
# Get the response from the LLAMA model
wrapped_result: WrappedGenerateResponse = response_queue.get()
if wrapped_result.status == "error":
yield InferenceResult(
code="error",
audio=None,
error=(
wrapped_result.response
if isinstance(wrapped_result.response, Exception)
else Exception("Unknown error")
),
)
break
# Check the response type
if not isinstance(wrapped_result.response, GenerateResponse):
raise TypeError(
f"Expected GenerateResponse, got {type(wrapped_result.response).__name__}"
)
result: GenerateResponse = wrapped_result.response
if result.action != "next":
segment = self.get_audio_segment(result)
if req.streaming: # Used only by the API server
yield InferenceResult(
code="segment",
audio=(sample_rate, segment),
error=None,
)
segments.append(segment)
else:
break
# Clean up the memoryView on GitHub (pinned to befe400174)
Solutions
- Pin/align client and server to the same fish-speech version (reinstall both sides)
- If using a custom or mocked backend, make it return GenerateResponse instances exactly
- Update the code — this check exists precisely to catch protocol drift, so don't suppress it; fix the source of the wrong type
Defensive patterns
Strategy: validation
Validate before calling
from fish_speech import GenerateResponse # adjust import to actual module resp = engine.inference(...) # pre-check versions before inferring import fish_speech assert fish_speech.__version__ == SERVER_VERSION
Type guard
from fish_speech import GenerateResponse
def is_generate_response(r) -> bool:
return isinstance(r, GenerateResponse) Try / catch
try:
for chunk in engine.inference(req):
...
except TypeError as e:
if "Expected GenerateResponse" in str(e):
raise RuntimeError("client/server version mismatch — align fish-speech versions") from e
raise Prevention
- Pin identical fish-speech versions on client and server
- Add a version/protocol handshake at connection setup
- Don't mock backends with plain dicts; return real GenerateResponse objects
When it happens
Trigger: Calling engine.inference()/inference_async()/tts()/warm_up() when the wrapped backend (model server or local model) yields a response object of an unexpected type — e.g. after a version mismatch where the backend returns a raw dataclass/dict instead of GenerateResponse.
Common situations: Mixing incompatible versions of fish-speech client and server (schema drift in the RPC/message protocol), a mocked or custom backend not returning the expected class, or deserialization producing a different class with the same shape.
Related errors
- Either text or tokens must be provided
- Unsupported part type: {part['type']}
- Unsupported part type: {type(part)}
- {i} is not a file or directory
- Reference ID '{id}' already exists
AI-assisted analysis of fishaudio/fish-speech@befe400174 (2026-08-27).
Data as JSON: /api/errors/142685dd5dc7cb86.
Report an issue: GitHub.