I have setup livekit on my local. But when running...
# ask-ai
c
I have setup livekit on my local. But when running my agent, I am getting the following error: Cannot connect to host 127.0.0.1:7880 ssl:default [[SSL] record layer failure (_ssl.c:1028)]
t
Thanks for reaching out, Rashmi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The error you're encountering suggests a mismatch between your agent's connection configuration and your LiveKit server setup. Here are the steps to resolve this issue: 1. Use Non-SSL Connection for Local Development • If you're running LiveKit locally in development mode, ensure your agent is configured to connect without SSL. Use the following connection URL:
Copy code
<ws://localhost:7880>
Ensure your agent's configuration uses this URL instead of an SSL-based one (e.g.,
wss://
). 2. Configure SSL for Local Development (Optional) • If you need SSL for local development, you'll need to set up SSL termination. This requires a domain, an SSL certificate, and a load balancer or reverse proxy to handle HTTPS/SSL termination. 3. Verify Server Status • Ensure your LiveKit server is running properly. Start it in development mode using the following command:
Copy code
livekit-server --dev
This should start an instance that your agent can connect to without SSL. Additional Troubleshooting • Confirm your LiveKit server is running on port 7880. • Ensure no firewall is blocking the connection. • Verify that the agent's
ws_url
configuration matches your server setup (HTTP vs HTTPS). Let me know if you need further assistance or if the issue persists after trying these steps.
c
how to view transcript in python agent?
t
Hey there! Let me walk you through the different ways you can view transcripts in a LiveKit Python agent. I'll break it down step by step, just like I'm explaining it to a friend. 1. Using
AgentSession
Events
Want to catch those transcription events? Here's a friendly way to listen in:
Copy code
from livekit.agents import AgentSession

@session.on("user_input_transcribed")
def on_transcript(transcript):
    if transcript.is_final:
        # Woohoo! We've got a final transcript
        print(f"Final transcript: {transcript.transcript}")
    else:
        # Catching those interim updates
        print(f"Interim transcript: {transcript.transcript}")
2. Accessing Current Transcript Property Need to grab the current transcript? It's super easy:
Copy code
# Snag the current transcript, including those interim results
current_text = voice_component.current_transcript
3. Using Session History Want to keep track of the whole conversation? We've got you covered:
Copy code
# Peek into the complete conversation history
conversation_history = session.history

# Pro tip: Save that history when shutting down
session.add_shutdown_callback(save_conversation_history)
4. Listening to Conversation Events Get real-time updates as conversations unfold:
Copy code
@session.on("conversation_item_added")
def on_conversation_item_added(item):
    # Catch those new conversation items as they come in
    print(f"New item added: {item}")
5. Custom STT Event Handling For the tech-savvy agents out there, here's how to handle STT events directly:
Copy code
from livekit.agents import stt, transcription

async def _forward_transcription(
    stt_stream: stt.SpeechStream,
    stt_forwarder: transcription.STTSegmentsForwarder,
):
    async for ev in stt_stream:
        stt_forwarder.update(ev)
        if ev.type == stt.SpeechEventType.INTERIM_TRANSCRIPT:
            print(ev.alternatives[0].text, end="")
        elif ev.type == stt.SpeechEventType.FINAL_TRANSCRIPT:
            print(" -> ", ev.alternatives[0].text)
6. Pipeline Nodes Access Pro move: Text transcripts are also available in real-time through the
llm_node
or
transcription_node
. Pick the method that feels right for your project. Whether you want real-time updates or a full conversation history, we've got you covered! Happy coding! 🚀 Sources: examples/other/transcription/README.md | Session recording and transcripts | LiveKit Docs | Transcriptions | LiveKit Docs | complex-agents/teleprompter/cartesia-ink.py
c
what is RoomOutputOptions(sync_transcription=False)
t
Hey there! Let me break down
RoomOutputOptions(sync_transcription=False)
in a way that's super easy to understand. It's basically a cool LiveKit setting that gives you more control over how transcriptions show up. What it does: • When
sync_transcription=False
is set, transcriptions pop up right away, without waiting to match the original speech perfectly. • This turns off the default synchronized transcription feature. Default behavior (when
sync_transcription=True
):
• Normally, transcriptions follow along with the agent's speech, showing text word by word in real-time. • If the agent gets interrupted, the transcription stops and adjusts to match what was actually said. Usage example:
Copy code
await session.start(
    agent=MyAgent(),
    room=ctx.room,
    room_output_options=RoomOutputOptions(sync_transcription=False),
)
When to use it: • When you want transcriptions to appear lightning-fast, without waiting for perfect timing. • When you need transcriptions to show up immediately as they're generated. • When speed matters more than perfectly synced playback. This option is part of the
RoomOutputOptions
dataclass and is super helpful for apps where getting transcriptions quickly is a top priority. Hope this helps you understand it better! Sources: Text and transcriptions | LiveKit Docs | livekit-agents/livekit/agents/voice/room_io/__init__.py
c
Is there a way to reduce delay for agent response?
t
Hey there! Want to make your LiveKit agent feel lightning-fast and super smooth? I've got some friendly tips to help reduce those pesky response delays. 1. Enable Preemptive Speech Generation • Think of this like getting a head start! Your agent can begin cooking up a response before the user even finishes talking. It's like having a conversation buddy who's always one step ahead. 😊 This helps when the speech-to-text is quicker than the voice activity detection. • Super easy to turn on - just use the
preemptive_generation
parameter in `AgentSession`:
Copy code
session = AgentSession(
    preemptive_generation=True,
    # other parameters...
)
2. Optimize Network and Infrastructure • Imagine your agent is like a delivery service - the closer your services are to each other, the faster the response! Keep your LLM, Speech-to-Text, and Text-to-Speech services close network-wise. • Keep an eye on those performance metrics - Time To First Token and Time To First Byte are your new best friends. • Choose speedy service providers and use pre-connect buffering to get things moving quickly. 3. TTS-Specific Optimizations • For Rime TTS, try the
reduce_latency
parameter. Just a heads up - it might make some words sound a bit funny, but hey, speed comes with trade-offs! 4. Minimize Connection Time • Use those long-lasting "warm" tokens when logging in. • Get your agent ready while generating tokens - multitasking for the win! 5. Handle Processing Delays • Sometimes delays happen, but don't worry! Here are some ways to keep users engaged: ◦ Give users a heads up that you're working on their request. ◦ Throw in some cute "thinking" messages like "Let me check that out for you..." ◦ Use dynamic, AI-generated thinking responses. ◦ Play some background audio to keep things interesting. By using these strategies, you'll create an agent experience that feels super responsive and friendly. Happy optimizing! 🚀 Sources: Agent speech and audio | LiveKit Docs | examples/voice_agents/preemptive_generation.py | AI Agents Framework | livekit/livekit_composite | DeepWiki | Rime integration guide | LiveKit Docs | Web and mobile frontends | LiveKit Docs
c
How to disable video in nodejs frontend
t
Hey there! Let me walk you through disabling video in a LiveKit Node.js frontend. I've got a couple of super easy ways to help you out. 1. Using React Components If you're working with a React app and
@livekit/components-react
, it's super simple! Just set the
video
prop to
false
on the
LiveKitRoom
component. Check out this quick example:
Copy code
<LiveKitRoom 
  video={false} 
  audio={false} 
  token={token} 
  serverUrl={process.env.NEXT_PUBLIC_LK_SERVER_URL} 
  onMediaDeviceFailure={(e) => {
    console.error(e);
    alert(
      'Error acquiring camera or microphone permissions. Please make sure you grant the necessary permissions in your browser and reload the tab',
    );
  }}
>
  <VideoConference />
</LiveKitRoom>
Pro tip: The
video
prop is pretty flexible – it can be a boolean or
VideoCaptureOptions
, and it defaults to
false
. This means your video won't start publishing right away when you connect to the LiveKit room. 2. Runtime Control Want more flexibility? No problem! You can totally control your video tracks on the fly. Imagine having buttons that let you toggle video during your session – just use something like
appActions.toggleVideo()
to turn video on and off as you need. Whether you want to disable video from the start or switch it up mid-session, these methods have got you covered. Hope this helps make your LiveKit setup a breeze! 😊 Sources: Subscribing to tracks | LiveKit Docs | src/room/track/LocalVideoTrack.ts | examples/nextjs/pages/minimal.tsx | docs/interfaces/LiveKitRoomProps.html
c
can you provide me dockerfile for voice-assistant-frontend ?
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!
c
my livekit project is in node and python. How can I deploy it to kubernetes cluster?