I feel like the generate_reply does not work very ...
# ask-ai
a
I feel like the generate_reply does not work very often when using gemini. Would it work to add a TTS and how do I use that in conjunction with the gemini live api? This is the code:
Copy code
session = AgentSession(
            tts=google.TTS(
                voice_name=voice,
            ),
            llm=google.realtime.RealtimeModel(
                model=llm_model,
                voice=voice,
                temperature=temperature,
                instructions="",
                input_audio_transcription=InputAudioTranscription(
                    model=transcription_model,
                    language=language,
                    prompt="Context is a phone call in language {language}",
                ),
                enable_affective_dialog=True,
                thinking_config=types.ThinkingConfig(include_thoughts=False),
            ),
            vad=silero.VAD.load(),
        )
t
Thanks for reaching out, Malte. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you integrate TTS with the Gemini Live API in LiveKit! You can use the Gemini TTS plugin for this. Let me walk you through the setup step-by-step: 1. Install the Plugin: If you're using Python, just run:
uv add "livekit-agents[google]~=1.2"
And for Node.js, use:
pnpm add @livekit/agents-plugin-google@1.x
2. Authentication: Make sure to set the
GOOGLE_API_KEY
or
GOOGLE_APPLICATION_CREDENTIALS
environment variable so the Google Gemini API or Vertex AI can authenticate properly. 3. Configure TTS: In Python, you can set it up like this: `from livekit.plugins import google session = AgentSession( tts=google.beta.GeminiTTS( model="gemini-2.5-flash-preview-tts", voice_name="Zephyr", instructions="Speak in a friendly and engaging tone." ), # Other configurations )`For Node.js, here’s how you can do it:
Copy code
import * as google from '@livekit/agents-plugin-google';

const session = new voice.AgentSession({
    tts: new google.beta.TTS({
        model: 'gemini-2.5-flash-preview-tts',
        voiceName: 'Zephyr',
        instructions: 'Speak in a friendly and engaging tone.'
    }),
    // Other configurations
});
4. Parameters: Feel free to choose models like
gemini-2.5-flash-preview-tts
and voices such as
Zephyr
or
Kore
. Adding instructions helps you control the tone and style exactly how you want it. 5. Integration with Gemini Live API: You can configure the TTS alongside the Gemini Live API for smooth real-time interactions. For example:
Copy code
session = AgentSession(
    llm=google.realtime.RealtimeModel(modalities=[Modality.TEXT]),
    tts="cartesia/sonic-3"
)
If you have any questions or need a hand with any part of this setup, just let me know—I’m here to help! Sources: .cursor/rules/agent-core.mdc | livekit-plugins/livekit-plugins-google/README.md | Gemini Live API plugin | LiveKit docs | Google AI and LiveKit | LiveKit Docs | Gemini TTS plugin guide | LiveKit Docs
a
I noticed you have modalities=text. Will this only work if I have this modality or will it also work when using audio for the realtime? Im mostly interested in using the TTS as a fallback for when it fails to generate a greeting
t
I'm happy to help you understand how the TTS functionality works with LiveKit's Gemini Live API! It supports both text and audio modalities, and here are a few key points to keep in mind: • Audio Modality: When you set up the Gemini Live API with
modalities=["AUDIO"]
or
["TEXT", "AUDIO"]
, it enables real-time voice interactions. This means spoken input gets transcribed, and the responses come back as audio, making conversations feel natural and smooth. • TTS Behavior: The built-in Gemini TTS works by generating the full audio response after processing the entire text, rather than streaming it bit by bit in real-time. It’s a straightforward approach that ensures clear and complete audio replies. • Fallback for Greetings: If you’d like to use TTS as a backup for greetings, you can configure the
RealtimeModel
with
modalities=["TEXT"]
. This way, you’ll get text responses that your TTS engine can then convert into audio, offering flexibility in how you deliver those greetings. • Streaming TTS: For true real-time streaming audio output, you might want to consider using a separate TTS engine like Cartesia, since the native Gemini TTS doesn’t support streaming audio as it processes the full text first. Please feel free to reach out if you'd like more help setting this up or have any other questions—I’m here to support you every step of the way! Sources: Gemini Live API plugin | LiveKit docs | Real-time AI Models & Streaming | livekit/livekit_composite | DeepWiki | plugins/google/src/beta/gemini_tts.test.ts