I just wonder whether I can use livekit for only ...
# ask-ai
f
I just wonder whether I can use livekit for only reading a text
t
Thanks for reaching out, Baymurat. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes, LiveKit can be used for text-only reading purposes. Here are the key points: • Configure text-only input/output: You can disable audio entirely by setting
audio_enabled=False
in
RoomOutputOptions
and enable text input by setting
text_enabled=True
in
RoomInputOptions
. • Read text streams: Text input is sent using TextStream to the
lk.chat
topic, and agent output is sent through TextStream to the
lk.transcription
topic. This allows you to process incoming text incrementally or as complete streams. • Use text-only agents: LiveKit provides examples of text-only agents that skip voice entirely. You can configure them with options like
room_input_options=RoomInputOptions(text_enabled=True, audio_enabled=False)
and
room_output_options=RoomOutputOptions(transcription_enabled=True, audio_enabled=False)
. The text streams feature works across all LiveKit client SDKs and supports flexible text processing methods. Sources: Text and transcriptions | LiveKit Docs | README.md
f
can you help with the flow?
t
Hey there! Let me walk you through how to use LiveKit for text-only reading – it's actually pretty straightforward! Basic Setup Flow Want to create a text-only agent? No worries! You'll just configure the AgentSession without any audio bells and whistles. Here's how you can set it up:
Copy code
async def entrypoint(ctx: JobContext):
    session = AgentSession(
        llm=openai.LLM(model="gpt-4o-mini"),
        # note that no TTS or STT are needed here
    )
    await session.start(
        agent=MyAgent(),
        room=ctx.room,
        room_input_options=RoomInputOptions(text_enabled=True, audio_enabled=False),
        room_output_options=RoomOutputOptions(transcription_enabled=True, audio_enabled=False),
    )
Text Input and Output Flow • Text Input: You'll receive text input using TextStream on the
lk.chat
topic. • Text Output: Your agent will send responses through TextStream on the
lk.transcription
topic. Think of it like your agent is always listening for messages on the
lk.chat
text stream and ready to chat back! Configuration Options • Want to go full text-only? Just set
audio_enabled=False
in
RoomOutputOptions
. Your agent will happily send text responses to the
lk.transcription
text stream topic. • If you want to disable text input, you can set
text_enabled=False
in
RoomInputOptions
. Alternative Input Methods Got other ways to send text? No problem! You've got options: • Send text input via:
generate_reply(user_input="user's input text")
• Catch the agent's response with
session.on("conversation_item_added", ev)
Event Handling Want to stay in the loop? You can get notified whenever a text message comes in or goes out by listening to the
conversation_item_added
event. This approach is super efficient – perfect for creating smooth, text-based AI conversations without any audio complexity. Pretty cool, right? Sources: examples/other/chat-stream-receiver.py | Text and transcriptions | LiveKit Docs
f
if i diable TTS, how it reads the text?
t
Hey there! Let me break down how LiveKit handles text processing when Text-to-Speech is turned off. It's actually pretty cool and straightforward. • Text Processing Without TTS: Think of it like a direct pipeline - the text from your language model goes straight through the transcription system without needing to be converted to audio. • Transcription Node Processing: This is where the magic happens! The transcription node takes your text and can do some neat customization. By default, it'll pass text through as-is, but you can totally tweak how it handles things if you want. • Text Stream Output: Here's the fun part - your processed text gets sent to the frontend in real-time. It uses LiveKit's text streams, and gets published to the
lk.transcription
topic, complete with sender details. • Configuration Control: Want to turn off text output completely? No problem! Just set
transcription_enabled=False
in
RoomOutputOptions
. Basically, LiveKit treats your text like a live, direct output stream - super flexible and powerful, without the need for audio synthesis. Pretty neat, right? Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Text and transcriptions | LiveKit Docs