agents icon indicating copy to clipboard operation
agents copied to clipboard

Google TTS (LiveKit Plugin) stops mid-way while LLM continues generating text

Open satheeshk50 opened this issue 4 months ago • 5 comments

Description

I am using LiveKit with the Google TTS plugin to build a workflow where:

The LLM generates text continuously.

The TTS speaks out the LLM output in real-time.

The problem is that Google TTS stops producing audio in the middle, even though the LLM continues generating the rest of the text. At the end, I receive:

Full text output from the LLM

Only partial audio output from Google TTS

So, TTS does not complete speaking the entire LLM response.

please explain and address this issue

error

{"message": "failed to synthesize speech, retrying in 2.0s\nTraceback (most recent call last):\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/tts/tts.py\", line 368, in _main_task\n    raise APIError(f\"no audio frames were pushed for text: {self._pushed_text}\")\nlivekit.agents._exceptions.APIError: no audio frames were pushed for text: Hello, Sarah Johnson! Welcome to the billing department at Cleveland General Medical Center in United States. I'm here to help with insurance, payments, or billing questions. For security, I may need to verify your identity. How can I assist you today? (body=None, retryable=True)", "level": "WARNING", "name": "livekit.agents", "tts": "livekit.plugins.google.tts.TTS", "attempt": 3, "streamed": true, "pid": 2232868, "job_id": "AJ_62Co5QHgSDuu", "timestamp": "2025-09-05T12:00:01.531793+00:00"}
{"message": "Error in _tts_inference_task\nTraceback (most recent call last):\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/tts/tts.py\", line 529, in __anext__\n    val = await self._event_aiter.__anext__()\n          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nStopAsyncIteration\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/utils/log.py\", line 16, in async_fn_logs\n    return await fn(*args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n    return await func(*args, **kwargs)  # type: ignore\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/voice/generation.py\", line 212, in _tts_inference_task\n    async for audio_frame in tts_node:\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/voice/agent.py\", line 408, in tts_node\n    async for ev in stream:\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/tts/tts.py\", line 532, in __anext__\n    raise exc  # noqa: B904\n    ^^^^^^^^^\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/opentelemetry/util/_decorator.py\", line 71, in async_wrapper\n    return await func(*args, **kwargs)  # type: ignore\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/lokesh/miniconda3/envs/pharma/lib/python3.12/site-packages/livekit/agents/tts/tts.py\", line 368, in _main_task\n    raise APIError(f\"no audio frames were pushed for text: {self._pushed_text}\")\nlivekit.agents._exceptions.APIError: no audio frames were pushed for text: Hello, Sarah Johnson! Welcome to the billing department at Cleveland General Medical Center in United States. I'm here to help with insurance, payments, or billing questions. For security, I may need to verify your identity. How can I assist you today? (body=None, retryable=True)", "level": "ERROR", "name": "livekit.agents", "pid": 2232868, "job_id": "AJ_62Co5QHgSDuu", "timestamp": "2025-09-05T12:00:03.535503+00:00"}

satheeshk50 avatar Sep 05 '25 07:09 satheeshk50

can you share a reproducible example?

longcw avatar Sep 08 '25 01:09 longcw

I have the same issue

Error: type='tts_error' timestamp=1758171177.2722018 label='livekit.plugins.google.tts.TTS' error=APITimeoutError('Request timed out.') recoverable=True`

DollarAkshay avatar Sep 18 '25 04:09 DollarAkshay

Same issues with elevenlabs

khushalcodiste avatar Oct 29 '25 17:10 khushalcodiste

I'm having the same issue - any resolution here?

alarche avatar Nov 10 '25 22:11 alarche

Limit the max chars of the llm prompt to be below the hard streaming limit of 60 seconds. Also consider different speaking rates for that. Adjust temperature to make it follow the instructions (might affect creativity).

https://docs.cloud.google.com/speech-to-text/docs/voice-activity-events

harryclaudius avatar Nov 25 '25 17:11 harryclaudius