melodic-hamburger-67426
08/07/2025, 11:05 AMtall-airline-16756
08/07/2025, 11:05 AMtall-airline-16756
08/07/2025, 11:06 AMmelodic-hamburger-67426
08/07/2025, 11:09 AMtall-airline-16756
08/07/2025, 11:09 AMuser_input_transcribed
event for multiple participants, it’s a good idea to give each participant their own session to keep things organized. Here’s a friendly rundown on how you can tackle this:
• Create Individual Sessions: Set up a separate session for each participant so their events don’t get mixed up.
• Attach Event Handlers: For every session, add a handler for the user_input_transcribed
event to keep track of what’s being transcribed.
• Enable Speaker Diarization: If your STT plugin offers it, turn on speaker diarization to easily tell who’s who.
• Dynamic Session Management: Create sessions when participants join and close them when they leave to keep everything neat and tidy.
This way, you’ll make sure each transcription event is linked to the right person. If you want, I’m happy to help with more details or share some code examples—just let me know!melodic-hamburger-67426
08/07/2025, 11:10 AMtall-airline-16756
08/07/2025, 11:10 AMasync def on_participant_connected(participant):
if participant.identity in sessions:
return # Session already exists
session = await create_transcription_session(ctx, participant)
sessions[participant.identity] = session
2. Create a Transcription Session: Let’s define a function that sets up and configures the transcription session. We’ll attach the user_input_transcribed
event handler to handle the transcriptions. async def create_transcription_session(ctx, participant):
session = AgentSession()
def on_transcription(event):
if event.is_final:
print(f"[{participant.identity}] {event.transcript}")
session.on("user_input_transcribed")(on_transcription)
# Configure and start the session
await session.start(agent=Agent(participant_identity=participant.identity))
return session
3. Manage Sessions Dynamically: Add event handlers to create sessions when participants join and to close them when they leave. ctx.room.on("participant_connected", on_participant_connected)
ctx.room.on("participant_disconnected", on_participant_disconnected)
async def on_participant_disconnected(participant):
session = sessions.pop(participant.identity, None)
if session:
await session.aclose()
This way, each participant gets their own session to handle transcription smoothly. If anything’s unclear or you want to dive deeper, just let me know—I’m here to help!melodic-hamburger-67426
08/07/2025, 11:11 AMtall-airline-16756
08/07/2025, 11:12 AM