data structure of a TranscriptionEvent
# ask-ai
b
data structure of a TranscriptionEvent
t
Thanks for reaching out, Rongrong. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Let me walk you through the data structure of a
TranscriptionEvent
in LiveKit — it’s got a few key parts: • transcribedParticipantIdentity (string): This tells you who the participant is whose speech got transcribed. • trackId (string): The server identifier (SID) for the audio track that’s being transcribed. • segments (array): A list of
TranscriptionSegment
objects that hold the actual transcription data. Now, each
TranscriptionSegment
includes: • id (string): A unique ID for that segment. • text (string): The transcribed text itself. • startTime (uint64): When the segment starts, in nanoseconds since the track began. • endTime (uint64): When it ends, also in nanoseconds. • final (boolean): This tells you if the segment is final — meaning it won’t be updated anymore. • language (string): The language code, like "en" for English. Just a heads up, different SDKs might add their own little extras to this structure. For instance, the Flutter SDK includes
firstReceivedTime
and
lastReceivedTime
to help with client-side timing, and JavaScript frontends keep track of similar timestamps for rendering and avoiding duplicates. If you want me to dive into the details for a specific SDK, just say the word — I’m here to help! Sources: lib/src/types/transcription_segment.dart | livekit-protocol/livekit/protocol/models.pyi | packages/livekit-rtc/src/transcription.ts | Sources/LiveKit/Protos/livekit_models.pb.swift | Transcriptions | LiveKit Docs
b
how to tell if the transcription participant is an agent or a user
t
Hey there! To figure out if a transcription participant is an agent or a user in LiveKit, you just need to check the
kind
property of the participant: • STANDARD: This means it's a regular end-user. • AGENT: This indicates an AI agent or bot. Most SDKs make this super easy with helper methods or properties: • In the Swift SDK, you can simply use the
isAgent
property to see if
kind
is
.agent
. • For the JavaScript/TypeScript SDK, just check
participant.kind === ParticipantKind.AGENT
or use the handy
isAgent
getter. • And in the Flutter SDK, the
isAgent
extension method helps you check if
kind == sdk.ParticipantKind.AGENT
. If you want, I’m here to help you with the implementation in any specific SDK—just let me know! Sources: Sources/LiveKit/Participant/Participant+Kind.swift | src/room/participant/Participant.ts | lib/exts.dart | Rooms, participants, and tracks | LiveKit Docs
b
show me an example in Flutter SDK
t
Here's a quick example to help you figure out if a transcription participant is an agent using the Flutter SDK: You can check the
kind
property of the
Participant
class to see if the participant is an agent. LiveKit offers a handy
ParticipantKind
enum that includes the
AGENT
type. Example:
Copy code
sdk.Participant participant = // obtain participant object

if (participant.kind == sdk.ParticipantKind.AGENT) {
  // This participant is an agent
}

// Or, if you prefer using an extension method:
extension ParticipantAgentExt on sdk.Participant {
  bool get isAgent => kind == sdk.ParticipantKind.AGENT;
}

if (participant.isAgent) {
  // This participant is an agent
}
If you want me to walk you through this or need more examples, just let me know—I’m here to help! Sources: lib/screens/agent_screen.dart | Rooms, participants, and tracks | LiveKit Docs | lib/src/types/attribute_typings.dart
b
is this
isAgent
already implemented or do we need to add this extension?
t
Hey there! Just a heads-up: the
isAgent
property isn’t built into the core LiveKit Flutter SDK by default. But no worries—it’s often added as a handy custom extension in example projects like the
voice-assistant-flutter
repo. If you want to use this feature, here’s a simple extension you can add:
Copy code
extension ParticipantAgentExt on sdk.Participant {
  bool get isAgent => kind == sdk.ParticipantKind.AGENT;
}
This little extension just checks if the participant’s
kind
is
ParticipantKind.AGENT
. If you’d like, I’m happy to help you get this set up in your project—just let me know! Sources: lib/support/agent_selector.dart | Sources/LiveKit/Types/Attributes/AttributeTypings.swift | pkg/rtc/types/typesfakes/fake_local_participant.go | Web and mobile frontends | LiveKit Docs
✅ 1