```async def entrypoint(ctx: JobContext): awai...
# ask-ai
r
Copy code
async 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?
t
Thanks for reaching out, Ayman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It looks like you're encountering a 429 error (Gemini TTS Quota Exceeded), which means the rate limits for the Google Gemini API have been reached. This shows up as an APIStatusError with the message "Gemini TTS: Rate limit error." The warning saying "failed to synthesize speech, retrying in 0.1s" indicates that the text-to-speech system ran into a hiccup while trying to create the speech and is giving it another shot. This can happen due to temporary issues like network glitches or API hiccups. The retry process is there to help bounce back from these brief problems, but if it keeps happening and hits the max retries, a more serious error will come up. Please feel free to reach out if you'd like me to explain anything further or if you need any more help—I’m here for you! Sources: agents/src/tts/tts.ts | livekit-plugins/livekit-plugins-google/livekit/plugins/google/tts.py
r
But I did not hear any audio from the TTS, though. It called the API multiple times that I was not aware of. I even changed my acc, still saying the same thing.
t
Sometimes, you might notice that Gemini TTS API calls don’t produce any audio output, and that can be a bit frustrating. Let’s walk through some common reasons this might happen: • Empty or Invalid API Response: If the API doesn’t return any audio content, the system simply won’t play any audio frames. • Text Input Issues: If the text you’re sending is empty or not formatted correctly, the audio won’t be generated. • Authentication or Configuration Errors: Double-checking your API keys and project settings is important, as incorrect details can cause silent failures. • Rate Limiting or Server Errors: Sometimes temporary issues like 429 or 5xx errors can interrupt audio generation during retries. • Unsupported Voice or Model: Using a voice name or model identifier that isn’t supported might result in no audio output. To help get things back on track, I recommend checking your logs for any API errors, making sure your text input is valid, verifying your credentials, and confirming that the API response actually includes audio data. If you’d like, I’m here to help you through any of these steps—just let me know! Sources: plugins/google/src/beta/gemini_tts.ts | livekit-agents/livekit/agents/voice/agent_activity.py | Gemini TTS plugin guide | LiveKit Docs
r
Another thing with the text, STT generated ghibrish bangla alphabets, no clear sentences. I used cartesia and set it is bangla as it do support it.
t
Thank you for reaching out! I understand how confusing it can be when the Bangla text generated by Cartesia STT comes out as gibberish. This happens because, at the moment, the Cartesia STT model integrated with LiveKit doesn’t support Bangla (Bengali). Currently, it supports languages like English, German, Spanish, French, Japanese, Portuguese, Chinese, and Hindi, but unfortunately not Bangla. So, when you try to transcribe Bangla speech, the system either defaults to English or misinterprets the Bangla sounds, which leads to that unclear output. To get accurate Bangla transcription, I’d recommend using an STT provider that specifically supports Bangla, such as Google Cloud STT (which supports "bn-IN" and "bn-BD") or Deepgram, which offers multilingual transcription. If you’d like, I’m here to help guide you through setting up one of these alternative STT providers—just let me know! Sources: examples/warm-transfer/warm_transfer.py | Cartesia STT | LiveKit Docs | Deepgram STT | LiveKit Docs | Cartesia STT plugin guide | LiveKit Docs
r
I even did without language set to bn though, still did not create any
t
I understand how important it is to get accurate transcriptions, so I want to share a bit about how Cartesia STT works with LiveKit. If no language is set, it automatically defaults to English ("en"). This means the system will try to transcribe the audio as English, which can understandably lead to some confusing or gibberish results if the spoken language is Bangla or another language that isn’t supported. Since Bangla isn’t currently supported by Cartesia STT, using the default English setting won’t quite do the trick. A great option would be to switch to an STT provider that explicitly supports Bangla, like Google Cloud STT or Deepgram. If you’d like, I’m here to help guide you through setting that up—just let me know! Sources: livekit-agents/livekit/agents/inference/stt.py | Cartesia STT | LiveKit Docs
r
(voice_agent) PS C:\Users\Ayman\OneDrive\Desktop\voice_agent> python agent.py console 2025-10-11 022448,208 - DEBUG asyncio - Using proactor: IocpProactor ================================================== Livekit Agents - Console ================================================== Press [Ctrl+B] to toggle between Text/Audio mode, [Q] to quit. 2025-10-11 022448,209 - INFO livekit.agents - starting worker {"version": "1.2.14", "rtc-version": "1.0.16"} 2025-10-11 022448,213 - INFO livekit.agents - initializing job runner {"tid": 24856} 2025-10-11 022448,213 - DEBUG asyncio - Using proactor: IocpProactor 2025-10-11 022448,213 - INFO livekit.agents - job runner initialized {"tid": 24856, "elapsed_time": 0.0} 2025-10-11 022450,376 - DEBUG livekit.agents - http_session(): creating a new httpclient ctx 2025-10-11 022450,378 - DEBUG livekit.agents - using audio io:
ChatCLI
->
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 ctx
t
It looks like you’ve encountered the 429 RESOURCE_EXHAUSTED error, which means the request rate or resource usage has gone beyond the Google Gemini TTS API quotas. Don’t worry—this error is retryable, and the LiveKit framework can automatically handle retries if it’s set up correctly. Here are some friendly steps to help you resolve this: • Make sure you have
max_retry
configured in your TTS settings to enable retries. For example:
Copy code
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