Why does the user's spoken content appear in about...
# ask-ai
b
Why does the user's spoken content appear in about three layers in “lk.transcription”?
t
Thanks for reaching out, RikuKomiya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When you look at the user's spoken content in "lk.transcription," you'll notice it comes through in about three layers. That’s because LiveKit uses an incremental transcription update system. Basically, it sends the full transcription each time it gets a bit more accurate, so you always have the clearest, most up-to-date version of what’s being said in real-time. For example, if someone says "Hello world," you might see updates like these: • { segment_id: "3", content: "Hello" } • { segment_id: "3", content: "Hello world" } • { segment_id: "3", content: "Hello world!" } Each new update replaces the last one, but the segment ID stays the same so you can easily track the changes. This way, the transcription stays accurate and easy to follow. If anything’s unclear or you want to dive deeper, just let me know—I’m here to help! Sources: VoiceAgent/Chat/Receive/TranscriptionStreamReceiver.swift | hooks/useDataStreamTranscriptions.ts
b
ではreact上では、正しく一つを表示したい場合はどうすればいい?
t
To show just the final transcription in React, you can use the
lk.transcription_final
flag that comes with the transcription updates. This handy flag tells you when a segment’s transcription is finalized, so you can filter out the in-progress bits and display only the final version. Here’s a simple way to do it: 1. Subscribe to the
lk.transcription
stream topic to get the transcription updates. 2. Look out for the
lk.transcription_final
flag in each update. When it’s
true
, update your state to show the final transcription for that segment. 3. Use the
lk.segment_id
to match updates and swap out earlier versions with the finalized text. This way, your React app will display only the polished, final transcription. If you want me to walk you through it or share some code examples, just give me a shout!
b
give me example code
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!