how can I combine consecutive utterances into a si...
# ask-ai
c
how can I combine consecutive utterances into a single transcript from the user?
t
Thanks for reaching out, Nathan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If you want to combine consecutive utterances from a user into a single transcript, LiveKit’s transcription features can help by merging segments based on timing and who’s speaking. Here’s a simple way to do it: 1. Gather the transcription segments using
RoomEvent.TranscriptionReceived
or a text stream handler. 2. Group those segments by participant and segment ID. 3. Merge segments from the same participant if: ◦ They happen within a short time window (like 1 second apart). ◦ The previous segment isn’t marked as
final
. 1. Sort everything by timestamp so it shows up in the right order. This way, consecutive utterances from the same user flow together smoothly. And if you’d like, I can share a code example that fits your framework—whether that’s React, Swift, Android, or something else. Just let me know! Sources: web/src/hooks/use-agent.tsx | web/src/hooks/use-agent.tsx | complex-agents/nutrition-assistant/nutrition-assistant-frontend/hooks/useCo... | hooks/useDataStreamTranscriptions.ts | livekit-plugins/livekit-plugins-speechmatics/livekit/plugins/speechmatics/s...
c
right, but how does the punctuation/capitalization work when merging these utterances? They are treated separately?
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!