fast-egg-39595
08/25/2025, 9:59 PMtall-airline-16756
08/25/2025, 10:00 PMtall-airline-16756
08/25/2025, 10:00 PMfrom google.genai.types import Modality
from livekit.plugins import google
session = AgentSession(
llm=google.beta.realtime.RealtimeModel(
modalities=[Modality.TEXT] # Text-only mode
),
tts=cartesia.TTS(), # Use separate TTS for audio output
)
• Turn Off Audio Input at the Session Level: Another way is to disable audio input for the whole session using RoomInputOptions. Check this out:
from livekit.agents.voice import AgentSession, RoomInputOptions
session = AgentSession(
llm=google.beta.realtime.RealtimeModel(),
room_input_options=RoomInputOptions(audio_enabled=False),
# ... other configurations
)
• Control Audio Input Dynamically: You can also switch audio input on or off during the session as needed. Here’s how:
session = AgentSession(...)
# Disable audio input after session starts
session.input.set_audio_enabled(False)
await session.start(...)
Each of these options has its perks! But if you want to tap into the Gemini Live API’s cool speech understanding features while keeping full control over speech output with your own TTS, going text-only is a great choice. Hope this helps you get set up smoothly!
Sources: Gemini Live API integration guide | LiveKit Docs | Text and transcriptions | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.pyfast-egg-39595
08/25/2025, 10:04 PMtall-airline-16756
08/25/2025, 10:05 PMfast-egg-39595
08/25/2025, 10:07 PMtall-airline-16756
08/25/2025, 10:08 PMfrom livekit.plugins import speechmatics
from livekit.agents import AgentSession
stt = speechmatics.STT(
enable_diarization=True,
speaker_active_format="[Speaker {speaker_id}] {text}",
end_of_utterance_silence_trigger=0.5,
)
• Gemini Configuration for Audio Output: Then, set up Gemini to respond with native audio by configuring it for audio-only modes:
from livekit.plugins import google
from google.genai.types import Modality
llm = google.beta.realtime.RealtimeModel(
model="gemini-2.0-flash-exp",
voice="Puck", # Pick your favorite voice
modalities=[Modality.AUDIO], # This makes responses audio-only
instructions="You are a helpful assistant. Respond naturally to the conversation.",
)
• Complete Agent Session: Finally, bring everything together in an AgentSession like this:
from livekit.agents import AgentSession
from livekit.plugins import google, speechmatics
from google.genai.types import Modality
session = AgentSession(
stt=speechmatics.STT(
enable_diarization=True,
speaker_active_format="[Speaker {speaker_id}] {text}",
end_of_utterance_silence_trigger=0.5,
),
llm=google.beta.realtime.RealtimeModel(
model="gemini-2.0-flash-exp",
voice="Puck",
modalities=[Modality.AUDIO],
instructions="You are responding to a conversation with multiple speakers. Pay attention to speaker identification in the format [Speaker ID] text.",
),
)
This way, Speechmatics will handle turning audio into text with speaker IDs, then send that to Gemini, which will reply with native audio. Pretty neat, right?
If you want me to walk you through any part of this or need some tweaks, just let me know—I’m here to help!
Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/gemini_t... | Gemini Live API integration guide | LiveKit Docs | Gemini Multimodal Live integration guide | LiveKit Docsfast-egg-39595
08/25/2025, 10:15 PMtall-airline-16756
08/25/2025, 10:15 PMfast-egg-39595
08/25/2025, 10:20 PMtall-airline-16756
08/25/2025, 10:22 PMsession = AgentSession(
stt=speechmatics.STT(
enable_diarization=True,
speaker_active_format="[Speaker {speaker_id}] {text}",
end_of_utterance_silence_trigger=0.5,
),
llm=google.beta.realtime.RealtimeModel(
model="gemini-2.0-flash-exp",
voice="Puck",
modalities=[Modality.TEXT], # Text-only input
instructions="You are a helpful assistant. Respond naturally to the conversation.",
),
room_input_options=RoomInputOptions(audio_enabled=False) # Disable audio input
)
With this setup:
• Speechmatics handles the audio and sends just the text to the LLM.
• The LLM doesn’t get or process any raw audio at all.
If you want me to walk through this more or help with your setup, just let me know—I’m happy to help!
Sources: agent/main.py | Text and transcriptions | LiveKit Docs | How to Set Up Speech-to-Text Input with Text-Only Output in LiveKit Agents | livekit-agents/livekit/agents/voice/agent.py | OpenAI Realtime API integration guide | LiveKit Docsfast-egg-39595
08/26/2025, 4:07 AMtall-airline-16756
08/26/2025, 4:08 AMtts_node method in your custom agent. Here’s a friendly little example to get you started:
from livekit.agents import Agent
from typing import AsyncIterable
class CustomAgent(Agent):
async def tts_node(self, text: AsyncIterable[str], model_settings):
async def process_text():
async for chunk in text:
if "No Reply Required" in chunk:
# Swap in a custom message here
yield "All cows will still go to heaven."
else:
yield chunk # Just pass through normal responses to TTS
return await super().tts_node(process_text(), model_settings)
Here’s what’s happening:
• The tts_node method catches the text coming from the LLM.
• If it spots "No Reply Required," it swaps that out with "All cows will still go to heaven."
• Otherwise, it just sends the original text along to the TTS system.
This way, you can handle certain responses differently without messing with the usual flow. If you want me to help tweak this further or have any questions, just let me know—I’m here to help!
Sources: Pipeline nodes and hooks | LiveKit Docs | Voice pipeline nodes | LiveKit Docs | pipeline-tts/tts_node.py | Modifying LLM output before TTS | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.pyfast-egg-39595
08/26/2025, 4:09 AMtall-airline-16756
08/26/2025, 4:10 AMmodel_settings parameter in the tts_node method is more of a general setup for coordinating different parts of the pipeline. It’s not actually where you tweak your ElevenLabs TTS model settings.
When you’re working with ElevenLabs, you set up the TTS details—like model, voice_id, language, and so on—right when you create your TTS object. Here’s a quick example:
from livekit.plugins import elevenlabs
tts = elevenlabs.TTS(
voice_id="ODq5zmih8GrVes37Dizd",
model="eleven_multilingual_v2",
language="en",
voice_settings=VoiceSettings(stability=0.7, similarity_boost=0.8)
)
In the tts_node method, you can still play around with the text before sending it off to the TTS engine. But just so you know, the main ElevenLabs settings—like voice and model—are set up separately when you initialize the TTS object.
If anything’s unclear or you want a hand with setting up ElevenLabs TTS, just give me a shout—I’m here to help!
Sources: livekit-agents/livekit/agents/voice/agent_activity.py | ElevenLabs TTS integration guide | LiveKit Docs | pipeline-tts/elevenlabs_tts.py | ElevenLabs integration guide | LiveKit Docs