How to capture transcript accurately in livekit ag...
# ask-ai
f
How to capture transcript accurately in livekit agent python worker to save to an object storage? Tried using
conversation_item_added
event, but the timestamps (created_at) in it are not accurate, especially for user messages.
t
Thanks for reaching out, Amjad. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd love to understand your setup a bit better so I can assist you more effectively. Could you share a few details with me? • Are there any specific configurations or customizations you've made in your LiveKit Python worker? • Which object storage service are you using to save the transcript? • Are you hoping to find a workaround to improve timestamp accuracy, or would you like some help exploring alternative ways to capture transcripts?
f
• Not much customizations • S3 • Mainly improve timestamp accuracy. Alternative way also works if that would address this problem.
t
To help you improve timestamp accuracy for user messages in your LiveKit Python worker and save the transcript to S3, I recommend using the
transcription_node
along with
TimedString
. This approach gives you word-level or sentence-level timestamps depending on your TTS provider. Let me walk you through the steps: 1. First, enable
use_tts_aligned_transcript=True
in your
AgentSession
configuration. 2. Next, implement a
transcription_node
method in your agent to access the timing information. This iterator yields a
TimedString
object that includes
start_time
and
end_time
for each word, measured in seconds relative to the start of the agent's current turn. 3. Then, you can adapt the approach used in the Transcriber Agent example to capture real-time transcriptions with timestamps and save them to a local file. After that, integrate an S3 client library like
boto3
to upload your transcript data to S3. For instance, inside the
on_transcript
function, you might initialize an S3 client and use the
put_object
or
upload_file
method to save the transcript data with timestamps directly to your S3 bucket. Just a heads-up, the
transcription_node
and
TimedString
features are currently experimental and might evolve in future SDK versions. If you’d like, I’m here to help you with any part of the implementation—just let me know! Sources: pipeline-stt/transcriber/transcriber.py | livekit-agents/livekit/agents/voice/room_io/_output.py | Docs::Agents | Session recording and transcripts | LiveKit Docs