{"record":{"id":"65ac97c9ac3b09ea","repo":"agentscope-ai/agentscope","slug":"cosyvoice-tts-synthesis-failed-no-audio-after-se","errorCode":null,"errorMessage":"CosyVoice TTS synthesis failed: no audio after {self.max_retries} attempts","messagePattern":"CosyVoice TTS synthesis failed: no audio after (.+?) attempts","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/tts/_dashscope/_cosyvoice_model.py","lineNumber":338,"sourceCode":"                        raise RuntimeError(\n                            \"CosyVoice TTS synthesis timed out after 30s\",\n                        )\n\n                    if full_text and not self._callback.has_audio_data():\n                        if attempt < self.max_retries - 1:\n                            logger.warning(\n                                \"CosyVoice TTS: no audio received, retrying \"\n                                \"(%d/%d) in %.1fs...\",\n                                attempt + 1,\n                                self.max_retries,\n                                delay,\n                            )\n                            await asyncio.sleep(delay)\n                            await self._reconnect()\n                            unsent = full_text\n                            delay *= 2\n                            continue\n                        raise RuntimeError(\n                            f\"CosyVoice TTS synthesis failed: no audio after \"\n                            f\"{self.max_retries} attempts\",\n                        )\n                    break\n\n                except RuntimeError:\n                    raise\n                except Exception as e:\n                    if attempt < self.max_retries - 1:\n                        logger.warning(\n                            \"CosyVoice TTS error, retrying (%d/%d) in \"\n                            \"%.1fs: %s\",\n                            attempt + 1,\n                            self.max_retries,\n                            delay,\n                            e,\n                        )\n                        await asyncio.sleep(delay)","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/tts/_dashscope/_cosyvoice_model.py#L320-L356","documentation":"CosyVoice real-time TTS finished sending text but no audio bytes were ever received, even after max_retries reconnect attempts. The library tracks whether any audio arrived via _callback.has_audio_data(); if empty after the final retry it aborts. Typical of server rejecting the request silently (auth, voice/model mismatch) or a dead connection.","triggerScenarios":"Calling synthesize() on the realtime CosyVoice model where full_text was sent but the callback never received audio data on the last retry attempt. Common with wrong voice/model parameters, missing API key, or service-side errors that close the stream without audio frames.","commonSituations":"Invalid DASHSCOPE_API_KEY, unsupported voice name for the chosen model, model not enabled for the account, or regional endpoint mismatch. Also after network interruptions where reconnect succeeds but the session state is lost.","solutions":["Validate DASHSCOPE_API_KEY and that the CosyVoice model/voice pair is enabled for the account.","Check the voice parameter matches a voice supported by the configured model.","Log and inspect the websocket close/error frames around the failure to see the server reason.","Increase max_retries if failures are transient.","Fall back to a non-realtime TTS model (e.g. dashscope HTTP synthesis) when realtime yields no audio."],"exampleFix":"# before\nmodel = DashScopeCosyVoiceTTSModel(voice=\"unknown-voice\")\n\n# after\nmodel = DashScopeCosyVoiceTTSModel(voice=\"longwan_v2\")  # a voice supported by the model","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    audio = await tts.synthesize(text)\nexcept RuntimeError as e:\n    if \"no audio after\" in str(e):\n        log.error(\"CosyVoice returned no audio; check API key/voice\")\n        audio = await fallback_tts.synthesize(text)\n    else:\n        raise","preventionTips":["Use a voice name confirmed supported by the chosen CosyVoice model.","Keep the API key valid with remaining quota.","Have a non-realtime TTS fallback configured."],"tags":["tts","dashscope","cosyvoice","websocket","no-audio","retry-exhausted"],"backgroundTag":"empty-response-from-stream","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}