hi how can i get transcript for realtime models an...
# ask-ai
l
hi how can i get transcript for realtime models and live models
t
Thanks for reaching out, biberim45. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to guide you through getting transcripts for realtime and live models in LiveKit! Here are some helpful methods you can use: • Realtime Access: You can use the
transcription_node
or
llm_node
to process and forward speech as it happens. Events like
user_input_transcribed
and
conversation_item_added
are great for capturing transcriptions in real time. • Session-Level Transcripts: If you'd like to access the full conversation history, the
session.history
property is your go-to. Plus, you can save the transcript after the session ends by using
add_shutdown_callback
. • Frontend Integration: You can forward transcriptions to clients using the
lk.transcription
text stream topic. There are also synchronization options available for agent speech transcriptions to keep everything smooth. • STT Plugin-Based Transcription: Another option is to use a standalone speech-to-text plugin to create a streaming transcription agent and forward the results to your clients. If you want to dive deeper into the implementation, I highly recommend checking out the Voice AI quickstart and the Transcriptions documentation. They have some fantastic resources that can really help you along the way. Sources: Session recording and transcripts | LiveKit Docs | Session recording and transcripts | LiveKit Docs | agents/src/voice/agent_activity.ts | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | Transcriptions | LiveKit Docs
l
how can i get or listening agent and participiants transcript
t
I'm glad you're interested in accessing agent and participant transcripts in LiveKit! Here are some friendly ways you can do that: • Frontend (Client SDKs): You can tap into the LiveKit client SDKs to listen for transcription events. For example, if you're using JavaScript, the
RoomEvent.TranscriptionReceived
event is a great way to catch real-time transcriptions. And don’t worry, similar options are available for Android and Flutter SDKs too. • Server-Side: If you want to handle transcriptions outside of the agent logic, you can register a text stream handler for the
lk.transcription
topic. This is especially helpful if you're looking to monitor or process things on the backend. • Agent Logic: You can also access real-time transcriptions through the
transcription_node
or by listening to events like
user_input_transcribed
and
conversation_item_added
. Plus, if you need the full conversation history, the
session.history
has you covered. If you want to dive deeper, I highly recommend checking out the Text and Transcriptions documentation—it’s a fantastic resource that walks you through everything step-by-step. Sources: Transcriptions | LiveKit Docs | Docs::Agents | src/components/playground/Playground.tsx | examples/other/chat-stream-receiver.py | Session recording and transcripts | LiveKit Docs
I'm happy to help you get started with accessing agent and participants' transcripts in LiveKit! Here are some friendly ways you can do that: • Frontend (Client SDKs): You can listen for real-time transcription updates using the
RoomEvent.TranscriptionReceived
event. For instance, if you're working with JavaScript, you might try something like this:
Copy code
room.on(RoomEvent.TranscriptionReceived, (segments, participant) => {
  segments.forEach((segment) => {
    console.log(`Transcription from ${participant.identity}: ${segment.text}`);
  });
});
• This kind of support is also available if you're using Android, Flutter, or other SDKs. • Another neat option is the
useTrackTranscription
hook for React components, which helps keep your transcriptions nicely synchronized. • Server-Side: If you want to handle transcriptions outside of the agent logic, you can register a text stream handler for the
lk.transcription
topic. Here's a quick example in Python:
Copy code
room.register_text_stream_handler(topic="lk.transcription", handler=on_transcription_received)
Agent Logic: You also have the option to access real-time transcriptions through the
transcription_node
or by listening to events like
user_input_transcribed
. Plus, if you need the full conversation history, you can retrieve it using
session.history
. If you'd like to dive deeper, feel free to check out the Text and Transcriptions documentation. It's a great resource to guide you step-by-step.
l
how can i get call history in text format for realtime models on serverside please can you give me examples on python
t
I'm glad you're looking to get the call history in text format for realtime models on the server-side using Python! Here's a friendly guide to help you through it: • Access Full Conversation History: You can easily retrieve the entire conversation history anytime by using the
session.history
property. • Listen to Real-Time Events: It’s super helpful to capture events like
user_input_transcribed
or
conversation_item_added
so you can log transcripts as they happen. • Save History After Session: When your session ends, you can save the conversation history by using the
add_shutdown_callback
method, storing it in a file like JSON or text. Here’s a simple example to load and save your chat history in Python:
Copy code
from livekit.agents import Agent, AgentSession, llm

async def entrypoint(ctx):
    chat_history = [
        {"role": "assistant", "content": "Hello, how can I help you?"},
        {"role": "user", "content": "Tell me about Paris."}
    ]

    chat_ctx = llm.ChatContext.empty()
    for item in chat_history:
        chat_ctx.add_message(role=item["role"], content=item["content"])

    session = AgentSession()
    agent = Agent(
        instructions="You are a helpful assistant.",
        llm=llm.realtime.RealtimeModel(model="gpt-4o-mini-realtime-preview"),
        chat_ctx=chat_ctx
    )

    await session.start(agent=agent, room=ctx.room)
    session.interrupt()
    session.generate_reply()

    # Save history to a file
    with open("conversation_history.json", "w") as file:
        file.write(session.history)
If you want to explore more or need additional details, feel free to check out the Text and Transcriptions documentation. I’m here if you have any questions along the way! Sources: livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | Recording agent sessions | LiveKit Docs | Recording agent sessions | LiveKit Docs | Realtime model integrations | LiveKit Docs | Session recording and transcripts | LiveKit Docs