rich-dusk-37560
09/02/2025, 8:44 AMfrom google.genai.types import Modality
session = AgentSession(
llm=google.beta.realtime.RealtimeModel(modalities=[Modality.TEXT]),
tts=cartesia.TTS(),
)
When I use Gemini Live API with a different TTS provider, I configure it with a text-only response modality and include a TTS plugin in the`AgentSession` configuration.
However, the model is now too verbosetall-airline-16756
09/02/2025, 8:44 AMtall-airline-16756
09/02/2025, 8:45 AMRealtimeModel with clear, short response instructions. Like this:
from livekit.plugins import google
session = AgentSession(
llm=google.beta.realtime.RealtimeModel(
model="gemini-2.0-flash-exp",
modalities=["AUDIO"],
instructions="Respond in short, concise sentences. Avoid repetition and unnecessary details.",
),
)
1. Use Text-Only Mode: Another way is to have the API output just text, then send that through a separate TTS provider. This gives you more control:
from google.genai.types import Modality
from livekit.plugins import google, cartesia
session = AgentSession(
llm=google.beta.realtime.RealtimeModel(modalities=[Modality.TEXT]),
tts=cartesia.TTS()
)
1. Custom Truncation Logic: You can also create a custom tts_node to keep the response length in check during synthesis.
For the best results, you might want to mix system instructions, text-only mode, and a customizable TTS provider. If you’d like, I’m here to help walk you through any of these steps!
Sources: Azure OpenAI Realtime API and LiveKit | LiveKit Docs | pipeline-tts/short_replies_only.py | Gemini TTS integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | Gemini Live API integration guide | LiveKit Docs