how i can get access to participant identity in th...
# ask-ai
r
how i can get access to participant identity in this case
Copy code
@session.on("user_input_transcribed")
    def on_transcript(ev):
✅ 1
t
Thanks for reaching out, simo.dev. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — you're asking how to get the participant identity inside your
user_input_transcribed
handler. I can help with that. It's common for LiveKit event objects to include a
participant
property. Try accessing
ev.participant.identity
(or
ev.participant.id
) inside your handler. For example:
Copy code
@session.on("user_input_transcribed")
def on_transcript(ev):
    participant = getattr(ev, "participant", None)
    if participant is not None:
        identity = getattr(participant, "identity", None) or getattr(participant, "id", None)
        print("participant identity:", identity)
    else:
        print("participant not present on event:", ev)
If that doesn't work, could you: • Share the runtime error or the printed
ev
structure (e.g.,
print(ev.__dict__)
)? • Tell me which LiveKit Python package/version you're using? With that I can give a precise field name or alternative. Sources: Layered Caller Verification for LiveKit SIP Calls | LiveKit | Turns overview | LiveKit Documentation, with interactive elements
r
ev has no participant
t
Thanks — good detail. You're correct:
ev
for
user_input_transcribed
does not include a
participant
field. Use the session's linked participant instead. For example:
Copy code
@session.on("user_input_transcribed")
def on_transcript(ev):
    linked = session.room_io.linked_participant
    if linked:
        print("participant identity:", linked.identity)
    else:
        print("no linked participant (session.room_io.linked_participant is None)")
If you need to target a specific participant in multi‑participant rooms, create a
RoomIO
bound to that identity when you start the session:
Copy code
room_io = RoomIO(session, room=ctx.room, participant="desired-participant-identity")
If that doesn't match your setup, please share: • the printed structure of
ev
(e.g.,
print(ev.__dict__)
) • the
livekit-agents
package version and I’ll guide the exact fix. Sources: Agent session | LiveKit Documentation | How to set a fixed participant for agent audio processing, with interactive elements
r
i get only this for env {'type': 'user_input_transcribed', 'transcript': 'hello there everyone this is a demo test of me you saw about that trying', 'is_final': False, 'speaker_id': None, 'language': 'en-US', 'created_at': 1778069614.004799}
t
Thanks — that event dict confirms it:
user_input_transcribed
does not include a participant object. The transcription payload you showed (
type
,
transcript
,
is_final
,
speaker_id
, etc.) is expected and won't contain the participant identity. What you can do instead: • Use the session's linked participant:
session.room_io.linked_participant
(or
session.linked_participant
depending on your setup). This is the participant the session is currently wired to for audio I/O.
Copy code
@session.on("user_input_transcribed")
def on_transcript(ev):
    linked = session.room_io.linked_participant
    if linked:
        print("participant identity:", linked.identity)
    else:
        print("no linked participant")
• If you need transcripts tied to a specific participant in a multi-participant room, create the session with a RoomIO bound to that identity:
Copy code
room_io = RoomIO(session, room=ctx.room, participant="desired-participant-identity")
Note:
speaker_id
in the event may be None in many setups; it is not a reliable substitute for participant identity unless your configuration explicitly populates it. If you want, share your
livekit-agents
version and how you create the session/RoomIO and I’ll suggest the exact code changes. , with interactive elements
r
i want to get identity using speaker_id
t
Thanks — I’m responding to your goal: use
speaker_id
to get the participant identity. Short answer: you cannot reliably map
speaker_id
to LiveKit
participant.identity
.
speaker_id
comes from STT speaker diarization (labels like "A", "B") and is not the same as LiveKit participant identity. It may also be None for short utterances. What you can do: • If you only need one participant’s audio, bind the session to that participant so all transcripts belong to that identity:
Copy code
room_io = RoomIO(session, room=ctx.room, participant="desired-participant-identity")
• For multi‑participant rooms, restrict which participant(s) feed the STT by configuring
RoomInputOptions
/
RoomIO
so you only process known identities. • Enable diarization in your STT config (e.g.,
speaker_labels=True
for AssemblyAI) if you want diarization output — but note diarization still won’t provide
participant.identity
. If you need a manual mapping approach, I can suggest workflows (for example, creating short registration prompts per participant to map diarization labels to identities), but I’ll need: • your
livekit-agents
SDK version, and • which STT provider and diarization settings you’re using. Which of those would you like to try? Sources: AssemblyAI STT | LiveKit Documentation | Deepgram STT | LiveKit Documentation | Speech-to-text (STT) models overview | LiveKit Documentation | Agent session | LiveKit Documentation | How to set a fixed participant for agent audio processing, with interactive elements