Does anyone have experience with setting up diariz...
# agents
b
Does anyone have experience with setting up diarization and an llm in LiveKit to work well like a realtime model with low latency? I'm having some issues with getting the _turn_detection & end_of_utterance_mode_ work well in using the diarization with Speechmatics and openAI llm and TTS models. The latency is not great and sometimes the agent interruption is too pre-maturely or the audio resumes from the previous agent interrupted audio. Here's my agent setup:
Copy code
# Set up participant event listener for future joins
    # Note: This is done before session creation to ensure it's ready

    # Get prewarmed models from process userdata
    vad = ctx.proc.userdata.get("vad")
    
    # Fall back to loading VAD if not prewarmed
    if not vad:
        logger.info("Loading VAD model...")
        vad = silero.VAD.load()
    
    # Initialize models that require job context
    logger.info("Initializing turn detector...")

    # Initialize EOU model for semantic turn detection
    turn_detector = EnglishModel()

    logger.info("Initializing noise cancellation...")
    noise_cancel = noise_cancellation.BVC()

    # # Determine which agent to use based on room name
    if room_name.startswith("my-demo"):
        stt = speechmatics.STT(
                language="en",
                enable_diarization=True,
                diarization_sensitivity=0.5,  
                speaker_active_format=SPEAKER_TAG_FORMAT,  
                prefer_current_speaker=True,
                end_of_utterance_silence_trigger=0.2,
                max_delay=1.0,
                enable_partials=True,
                end_of_utterance_mode=EndOfUtteranceMode.ADAPTIVE,
            )
        agent = MyAgent(ctx, stt=stt)
        session = AgentSession(
            llm=openai.LLM(model="gpt-4o"),
            tts=openai.TTS(
                model="gpt-4o-mini-tts",
                voice="sage",
                instructions=INSTRUCTIONS
            ),
            turn_detection=turn_detector,  # Use LiveKit EOU model
            stt=stt,
            vad=vad,  # Use prewarmed model
            min_endpointing_delay=0.2,
            max_endpointing_delay=5.0,
        )