where do I import ModelSettings from now in the la...
# ask-ai
c
where do I import ModelSettings from now in the latest livekit version?
t
Thanks for reaching out, Aaron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
In the latest version of LiveKit, you can import
ModelSettings
from the
livekit.agents.voice
module. The import statement would look like this:
Copy code
from livekit.agents.voice import ModelSettings
If you have any further questions, feel free to ask! Sources: Tree View: | dse-workbench
c
where do I import WorkerType from in the latest livekit
t
In the latest version of LiveKit, you can import
WorkerType
from the
livekit.agents
module. The import statement would look like this:
Copy code
from livekit.agents import WorkerType
If you have any further questions, feel free to ask! Sources: Tree View: | dse-workbench
c
where do I import WorkerPermissions from?
t
In the latest version of LiveKit, the
WorkerPermissions
class is part of the agents module. However, the exact import statement is not explicitly mentioned in the available documentation. It is likely to be:
Copy code
from livekit.agents import WorkerPermissions
If this does not work or you need further assistance, please let me know! Sources: WorkerPermissions | LiveKit Agents
c
is published_tracks a function in livekit? I get this error agent_worker_1 | ERROR 2025-05-12 183009,187 job_proc_lazy_main 158 140143684737920 unhandled exception while running the job task agent_worker_1 | Traceback (most recent call last): agent_worker_1 | File "/app/jobhive/interview/agents/worker_agent.py", line 452, in entrypoint agent_worker_1 | tracks = [t for t in p.published_tracks if t.kind == "audio"] agent_worker_1 | ^^^^^^^^^^^^^^^^^^ agent_worker_1 | AttributeError: 'RemoteParticipant' object has no attribute 'published_tracks' agent_worker_1 | ERROR 2025-05-12 183009,187 job_proc_lazy_main 158 140143684737920 unhandled exception while running the job task agent_worker_1 | Traceback (most recent call last): agent_worker_1 | File "/app/jobhive/interview/agents/worker_agent.py", line 452, in entrypoint agent_worker_1 | tracks = [t for t in p.published_tracks if t.kind == "audio"] agent_worker_1 | ^^^^^^^^^^^^^^^^^^ agent_worker_1 | AttributeError: 'RemoteParticipant' object has no attribute 'published_tracks' agent_worker_1 | 2025-05-12 183009,187 - ERROR livekit.agents - unhandled exception while running the job task agent_worker_1 | Traceback (most recent call last): agent_worker_1 | File "/app/jobhive/interview/agents/worker_agent.py", line 452, in entrypoint agent_worker_1 | tracks = [t for t in p.published_tracks if t.kind == "audio"] agent_worker_1 | ^^^^^^^^^^^^^^^^^^ agent_worker_1 | AttributeError: 'RemoteParticipant' object has no attribute 'published_tracks' {"p
t
It seems that the
RemoteParticipant
object in LiveKit does not have an attribute or function named
published_tracks
. This might be causing the error you are encountering. You may want to check the LiveKit documentation or the implementation of
RemoteParticipant
to confirm the available attributes and methods. If you need further assistance, feel free to ask!
c
'AgentSession' object has no attribute 'agent'. Did you mean: '_agent'? In this code
Copy code
await session.agent.send_initial_greeting(session)
What is the correct way?
t
It seems that the
AgentSession
object does not have an
agent
attribute, which is why you are encountering this error. Instead, the agent is passed as a parameter to the
start()
method of the
AgentSession
object. Here's an example of the correct usage:
Copy code
session = AgentSession(
    stt=deepgram.STT(),
    llm=openai.LLM(),
    tts=cartesia.TTS(),
    vad=silero.VAD.load(),
    turn_detection=turn_detector.MultilingualModel(),
)
await session.start(
    room=ctx.room,
    agent=Agent(instructions="You are a helpful voice AI assistant."),
    room_input_options=RoomInputOptions(
        noise_cancellation=noise_cancellation.BVC(),
    ),
)
In this example, the agent is passed to the
start()
method rather than being accessed as an attribute of the session. Let me know if you need further clarification! Sources: Building voice agents | LiveKit Docs
c
how do I fix this error AttributeError: 'RemoteParticipant' object has no attribute 'published_tracks'
t
The error occurs because the
RemoteParticipant
object does not have an attribute named
published_tracks
. Instead, you should use the
track_publications
attribute to access a remote participant's tracks. Here's an example:
Copy code
tracks = [t for t in p.track_publications.values() if t.kind == "audio"]
The
track_publications
attribute is a dictionary mapping track SIDs to track publications. Let me know if you need further assistance! Sources: livekit.rtc API documentation | RemoteParticipant | LiveKit JS Client SDK - v2.8.1 | RemoteParticipant class - livekit_client library - Dart API
c
how can I save the users transcripts
t
The provided documentation does not include specific details on how to save user transcripts in LiveKit. However, if you are using LiveKit's real-time transcription features, you can capture the transcriptions as they are generated and save them to a database or file system of your choice. If you need further guidance or have additional details about your setup, feel free to share, and I’ll do my best to assist!
c
can you provide an example of capturing transcripts
t
Here are some examples of how you can capture transcripts in LiveKit: 1. Using Speech-to-Text (STT) functionality:
Copy code
async def _forward_transcription(stt_stream: stt.SpeechStream, stt_forwarder: transcription.STTSegmentsForwarder):
    """Forward the transcription to the client and log the transcript in the console"""
    async for ev in stt_stream:
        if ev.type == stt.SpeechEventType.FINAL_TRANSCRIPT:
            print(" -> ", ev.alternatives[0].text)
        # ...
        stt_forwarder.update(ev)
1. Saving conversation history to a JSON file:
Copy code
async def write_transcript():
    current_date = datetime.now().strftime("%Y%m%d_%H%M%S")
    filename = f"/tmp/transcript_{ctx.room.name}_{current_date}.json"
    with open(filename, 'w') as f:
        json.dump(session.history.to_dict(), f, indent=2)
    print(f"Transcript for {ctx.room.name} saved to {filename}")

ctx.add_shutdown_callback(write_transcript)
1. Using the transcription protocol with TTSSegmentsForwarder:
Copy code
tts_forwarder = transcription.TTSSegmentsForwarder(
    room=ctx.room, participant=ctx.room.local_participant
)

# For single segment
text = "Hello world, this is a single segment"
tts_forwarder.push_text(text)
tts_forwarder.mark_text_segment_end()

# For streamed text
for chunk in _text_to_chunks(streamed_text):
    tts_forwarder.push_text(chunk)
tts_forwarder.mark_text_segment_end()
Let me know if you need further clarification or assistance! Sources: Tree View: | dse-workbench | Session recording and transcripts | LiveKit Docs | Tree View: | dse-workbench
c
in agents 1.0, what is the valid parameters for TrackSource
t
I'm sorry, but I don't have the information you need at the moment. If you would like a member of the LiveKit team to respond, please ask your question in one of the other channels.