agentscope-ai/agentscope · error · RuntimeError
TTS synthesis failed: no audio after {self.max_retries} atte
Error message
TTS synthesis failed: no audio after {self.max_retries} attempts What it means
Realtime DashScope TTS synthesis sent the full text but received no audio within the retry loop; after max_retries attempts (with reconnect + exponential backoff) the model resets state and raises. Distinct from a timeout: the flow completed but zero audio bytes arrived.
Source
Thrown at src/agentscope/tts/_dashscope/_realtime_model.py:433
self._callback.finish_event.wait,
)
if full_text and not self._callback.has_audio_data():
if attempt < self.max_retries - 1:
logger.warning(
"TTS: no audio received, retrying (%d/%d) in "
"%.1fs...",
attempt + 1,
self.max_retries,
delay,
)
await asyncio.sleep(delay)
await self._reconnect()
unsent = full_text
delay *= 2
continue
self._reset_state()
raise RuntimeError(
f"TTS synthesis failed: no audio after "
f"{self.max_retries} attempts",
)
break
except WebSocketConnectionClosedException:
if attempt < self.max_retries - 1:
logger.warning(
"TTS WebSocket closed, retrying (%d/%d) in %.1fs...",
attempt + 1,
self.max_retries,
delay,
)
await asyncio.sleep(delay)
await self._reconnect()
unsent = full_text
delay *= 2
else:View on GitHub (pinned to e90f1c7592)
Solutions
- Verify DASHSCOPE_API_KEY validity and quota.
- Confirm the voice/model combination is supported.
- Inspect websocket close codes/error messages logged near the failure.
- Retry at the call site with fresh connect(); if persistent, fall back to non-realtime synthesis.
- Report/check dashscope status page for outages.
Example fix
# before
audio = await model.synthesize(text)
# after
try:
audio = await model.synthesize(text)
except RuntimeError:
await model.disconnect()
await model.connect()
audio = await model.synthesize(text) Defensive patterns
Strategy: fallback
Try / catch
try:
audio = await model.synthesize(text)
except RuntimeError as e:
if "no audio after" in str(e):
await model.disconnect()
await model.connect()
audio = await model.synthesize(text)
else:
raise Prevention
- Verify API key/quota and supported voice before sessions.
- Monitor dashscope service status.
- Configure a non-realtime fallback TTS model.
When it happens
Trigger: Calling synthesize() on the realtime model where the websocket accepts text but no binary audio frames come back, on the final retry attempt. Caused by auth failures, unsupported voice/model params, server errors, or a half-dead connection.
Common situations: Bad or quota-exhausted DASHSCOPE_API_KEY, mismatched voice for the model, dashscope service incidents, network middleboxes that allow the handshake but drop binary frames.
Related errors
- CosyVoice TTS synthesis failed: no audio after {self.max_ret
- TTS model is not connected. Call `connect()` first.
- CosyVoice TTS synthesis timed out after 30s
- TTS model is not connected. Call `connect()` first.
- Feishu channel requires 'lark-oapi' (pip install lark-oapi).
AI-assisted analysis of agentscope-ai/agentscope@e90f1c7592 (2026-08-28).
Data as JSON: /api/errors/c02e021a809c2019.
Report an issue: GitHub.