Hey, I am building a voice to voice agent using Ge...
# ask-ai
l
Hey, I am building a voice to voice agent using Gemini Live. I want to get Events of the conversation, like when user starts and stop speaking. Whats the best way to do that ? Have added to this to monitor all events, but no event is getting logged.
Copy code
def log_all_events(event_name: str, *args, **kwargs):
            logger.info(f"🔔 EVENT FIRED: {event_name}, args count: {len(args)}")
            if args:
                logger.info(f"   First arg type: {type(args[0])}")
            if original_emit:
                return original_emit(event_name, *args, **kwargs)

        if hasattr(session, '_event_emitter'):
            session._event_emitter.emit = log_all_events
t
Thanks for reaching out, Pulkit. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're looking to monitor when a user starts and stops speaking in a Gemini Live session! You can do this by using the
input_speech_started
and
input_speech_stopped
events. These handy events are triggered by the server-side Voice Activity Detection (VAD) and are tailored specifically for Gemini Live integrations. Here’s a simple example to help you listen to these events in your code:
Copy code
@session.on("input_speech_started")
def on_input_speech_started():
    print("User started speaking")

@session.on("input_speech_stopped")
def on_input_speech_stopped():
    print("User stopped speaking")
Just a quick tip: make sure your session object is properly initialized and these event handlers are registered correctly so you can capture the events smoothly during your session. If you need any more help with this, feel free to ask—I’m here to help! Sources: Agent Session & Client Integration | livekit/livekit_composite | DeepWiki | Agents v0.x migration guide - Python | LiveKit Docs | Agents v0.x migration guide - Node.js | LiveKit Docs