can you share a code example of how to use RoomOpt...
# ask-ai
h
can you share a code example of how to use RoomOptions? this is what I have currently: await session.start( agent=agent, room=ctx.room, room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC(), close_on_disconnect=False, # Disable auto-close to allow cleanup delete_room_on_close=False, ), room_output_options=RoomOutputOptions(transcription_enabled=True), )
✅ 1
t
Thanks for reaching out, Ahmed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your request for a code example showing how to use RoomOptions (you’re currently passing RoomInputOptions/RoomOutputOptions). Below is a concise Python example using the unified
RoomOptions
(recommended in modern Python SDKs). It mirrors your settings: background noise cancellation, disable auto-close, and enable transcription.
Copy code
from livekit.agents import room_io
from livekit.plugins import noise_cancellation

room_options = room_io.RoomOptions(
    # enable audio/video inputs as needed
    audio_input=room_io.AudioInputOptions(
        noise_cancellation=noise_cancellation.BVC(),  # background voice cancellation
    ),
    video_input=True,  # set to False if you don't want video
    # text/transcription output options
    text_output=room_io.TextOutputOptions(
        transcription_enabled=True,
        sync_transcription=False,  # set True if you need real-time sync
    ),
    participant_identity="user_123",        # optional: target participant identity
    close_on_disconnect=False,             # disable auto-close to allow cleanup
    delete_room_on_close=False,            # do not delete room automatically
)

await session.start(
    agent=agent,
    room=ctx.room,
    room_options=room_options,
)
If you prefer to keep separate input/output objects (older style), I can show the equivalent, or if you want different noise-cancellation settings or participant targeting, tell me what you want and I’ll adapt the snippet. Sources: Agent session | LiveKit Documentation, with interactive elements
h
what does sync_transcription do?
t
You’re asking what
sync_transcription
does — thanks for the clear question. •
sync_transcription=True
(sync mode): transcribed text is synchronized with the agent’s spoken audio in real time (word-by-word). If the agent is interrupted, the transcription is truncated to match what was actually spoken. •
sync_transcription=False
(async mode): transcriptions are delivered to the client as soon as they’re available, without aligning to live audio playback. This can reduce perceived latency but you lose word-level audio/text sync. When to use which: • Use True if you need tight audio↔️text alignment (e.g., live captions or highlighting words as spoken). • Use False if lower latency is more important than per-word synchronization (e.g., quick post-utterance transcripts). If you tell me your use case (live captions, post-call transcript, low-latency UX), I can recommend the best setting. Sources: Text and transcriptions | LiveKit Documentation, with interactive elements