rough-intern-57330
10/10/2025, 8:12 PMasync def entrypoint(ctx: JobContext):
await ctx.connect() # Connect to the LiveKit room
agent = Agent(
instructions="""You are a helpful voice assistant fluent in both English and Bangla. You should respond in the same language the user speaks, and seamlessly switch languages as needed. Your responses should be concise and clear."""
)
session = AgentSession(
vad = silero.VAD.load(),
stt = cartesia.STT(
model="ink-whisper",
),
llm = google.LLM(
model="gemini-2.5-flash-preview-09-2025",
# gemini_tools=[types.GoogleSearch(), ...], # Uncomment and add tools if needed
),
tts = google.beta.GeminiTTS(
model="gemini-2.5-flash-preview-tts",
voice_name="Sulafat", # Test out voice in Google AI Studio (https://aistudio.google.com/live)
)
)
# Define your agent and start the session.
await session.start(agent=agent, room=ctx.room)
# You can send an initial greeting
await session.generate_reply(instructions="Greet the user in Bangla and ask how you can help.")
if __name__ == "__main__":
# The cli.run_app function starts the worker and waits for jobs.
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
I have written the code block following the documentation and videos. I still can't figure out the problems properly, so far I got:
1. Gemini TTS Quota Exceeded (429 Errors) # which does not make any sense to me. I could not even hear a single thing. I am sure I used the correct supported models.
2. I am getting this initially, ''WARNING livekit.agents - failed to synthesize speech, retrying in 0.1s''
Can anyone help me figure this out?tall-airline-16756
10/10/2025, 8:12 PMtall-airline-16756
10/10/2025, 8:13 PMrough-intern-57330
10/10/2025, 8:18 PMtall-airline-16756
10/10/2025, 8:19 PMrough-intern-57330
10/10/2025, 8:20 PMtall-airline-16756
10/10/2025, 8:21 PMrough-intern-57330
10/10/2025, 8:22 PMtall-airline-16756
10/10/2025, 8:23 PMrough-intern-57330
10/10/2025, 8:27 PMChatCLI -> AgentSession -> TranscriptSynchronizer -> ChatCLI
2025-10-11 022450,378 - DEBUG livekit.agents - using transcript io: AgentSession -> TranscriptSynchronizer -> ChatCLI
2025-10-11 022450,383 - INFO google_genai.models - AFC is enabled with max remote calls: 10.
2025-10-11 022450,988 - INFO google_genai.models - AFC remote call 1 is done.
2025-10-11 022451,207 - INFO google_genai.models - AFC is enabled with max remote calls: 10.
2025-10-11 022451,979 - DEBUG livekit.agents - received user transcript {"user_transcript": " This is what you do.", "language": "en"}
2025-10-11 022451,983 - INFO google_genai.models - AFC is enabled with max remote calls: 10.
2025-10-11 022454,556 - INFO google_genai.models - AFC remote call 1 is done.
2025-10-11 022454,678 - INFO google_genai.models - AFC is enabled with max remote calls: 10.
2025-10-11 022455,475 - WARNING livekit.agents - failed to synthesize speech, retrying in 0.1s {"tts": "livekit.plugins.google.beta.gemini_tts.TTS", "attempt": 1, "streamed": false}
Traceback (most recent call last):
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\livekit\plugins\google\beta\gemini_tts.py", line 203, in _run
response = await self._tts._client.aio.models.generate_content(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\google\genai\models.py", line 6709, in generate_content
response = await self._generate_content(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\google\genai\models.py", line 5544, in _generate_content
response = await self._api_client.async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\google\genai\_api_client.py", line 1326, in async_request
result = await self._async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\google\genai\_api_client.py", line 1271, in _async_request
return await self._async_retry( # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\tenacity\asyncio\__init__.py", line 111, in call
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\tenacity\asyncio\__init__.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\tenacity\_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\tenacity\__init__.py", line 420, in exc_check
raise retry_exc.reraise()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\tenacity\__init__.py", line 187, in reraise
raise self.last_attempt.result()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\AppData\Roaming\uv\python\cpython-3.12.9-windows-x86_64-none\Lib\concurrent\futures\_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\AppData\Roaming\uv\python\cpython-3.12.9-windows-x86_64-none\Lib\concurrent\futures\_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\tenacity\asyncio\__init__.py", line 114, in call
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\google\genai\_api_client.py", line 1216, in _async_request_once
await errors.APIError.raise_for_async_response(response)
File "C:\Users\Ayman\OneDrive\Desktop\voice_agent\.venv\Lib\site-packages\google\genai\errors.py", line 166, in raise_for_async_response
raise ClientError(status_code, response_json, response)
google.genai.errors.ClientError: 429 RESOURCE_EXHAUSTED. {'error': {'code': 429, 'message': 'You exceeded your current quota, please check your plan and billing details. For more information on this error, head to:
RESOURCE_EXHAUSTED, retryable=True)
2025-10-11 022458,716 - INFO livekit.agents - shutting down worker {"id": "unregistered"}
2025-10-11 022458,716 - DEBUG livekit.agents - shutting down job task {"reason": "", "user_initiated": false}
2025-10-11 022458,717 - DEBUG livekit.agents - job exiting {"reason": "", "tid": 24856, "job_id": "simulated-job-4b4b4562953c"}
2025-10-11 022500,738 - DEBUG livekit.agents - session closed {"reason": "job_shutdown", "error": null}
2025-10-11 022500,738 - DEBUG livekit.agents - http_session(): closing the httpclient ctxtall-airline-16756
10/10/2025, 8:28 PMmax_retry configured in your TTS settings to enable retries. For example:
from livekit.plugins.google import TTS
tts_plugin = TTS(
api_key="your-key",
conn_options=APIConnectOptions(max_retry=3) # Enable retries
)
• Take a moment to check your Google Cloud quotas for the Gemini TTS models and consider requesting higher limits if you’re hitting those caps.
• Try optimizing how often you send requests by batching or queuing TTS requests to reduce the load.
• Also, ensure you’re using supported models and voices like gemini-2.5-flash-preview-tts and Sulafat.
If you’d like, I’m here to help you walk through these steps or review your configuration—just let me know!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real... | agents/src/tts/tts.ts | Gemini TTS plugin guide | LiveKit Docs