rhythmic-jordan-68259
08/11/2025, 7:34 PMtall-airline-16756
08/11/2025, 7:34 PMtall-airline-16756
08/11/2025, 7:34 PMrhythmic-jordan-68259
08/12/2025, 2:37 PMtall-airline-16756
08/12/2025, 2:38 PMfiller_words
option in the STT settings to sprinkle in natural filler words like "um" or "uh" when the tools are running. It adds a touch of realism to the interaction.
These little touches can make waiting feel smoother and keep things more engaging for users. If you want, I’m happy to help you with the specifics on how to set any of these up!rhythmic-jordan-68259
08/12/2025, 2:39 PMtall-airline-16756
08/12/2025, 2:40 PMimport asyncio
from livekit.agents import function_tool, RunContext
@function_tool()
async def search_knowledge_base(
self,
context: RunContext,
query: str,
) -> str:
# Send a verbal status update to the user after a short delay
async def _speak_status_update(delay: float = 0.5):
await asyncio.sleep(delay)
await context.session.generate_reply(instructions=f"""
You are searching the knowledge base for \"{query}\" but it is taking a little while.
Update the user on your progress, but be very brief.
""")
status_update_task = asyncio.create_task(_speak_status_update(0.5))
# Perform search (function definition omitted for brevity)
result = await _perform_search(query)
# Cancel status update if search completed before timeout
status_update_task.cancel()
return result
• Filler Words in Speech-to-Text (STT): Want to make the speech-to-text output sound more natural by including filler words like "um" or "uh"? Just turn on the filler_words
option in your STT settings. Here’s how you can do it:
from livekit.agents import stt
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
stt=stt.STT(
filler_words=True,
# Other STT options
),
# ... other components
)
await session.start(room=ctx.room)
These tweaks should help you add both verbal status updates and filler words smoothly. If you run into any questions or want to chat more about these, I’m here to help!rhythmic-jordan-68259
08/12/2025, 2:49 PMtall-airline-16756
08/12/2025, 2:49 PMgenerate_reply
method to keep users in the loop with verbal feedback during those longer operations. Check out this example:
import asyncio
from livekit.agents import function_tool, RunContext
@function_tool()
async def search_knowledge_base(
self,
context: RunContext,
query: str,
) -> str:
# Here’s a little helper to send a quick verbal update after a short pause
async def _speak_status_update(delay: float = 0.5):
await asyncio.sleep(delay)
await context.session.generate_reply(instructions=f"""
You are searching the knowledge base for \"{query}\" but it is taking a little while.
Update the user on your progress, but be very brief.
""")
status_update_task = asyncio.create_task(_speak_status_update(0.5))
try:
# Now, do the actual search
result = await _perform_search(query)
# If the search finishes before the update, cancel the status update to keep things tidy
status_update_task.cancel()
return result
except asyncio.CancelledError:
return "Operation cancelled."
• Filler Words in Speech-to-Text: To make your speech-to-text experience more natural, you can turn on filler words in the Deepgram STT plugin by setting the filler_words
parameter to True
. Here’s how you do it:
from livekit.plugins import deepgram
# Initialize the STT with filler_words enabled (it’s True by default, but here’s how to be explicit)
stt = deepgram.STT(
model="nova-3",
language="en-US",
filler_words=True # This turns on filler words
)
# Or, if you want to update the settings on the fly:
await stt.update_options(filler_words=True)
With these steps, you’ll be all set to add helpful verbal status updates and manage filler words smoothly for Langgraph. If you have any questions or want to dive deeper, just let me know—I’m here to help!
Sources: External data and RAG | LiveKit Docs | Handling RAG Delays in Voice Agents | LiveKit Docs | Deepgram integration guide | LiveKit Docs | STTOptions | LiveKit Agentsrhythmic-jordan-68259
08/12/2025, 8:24 PMtall-airline-16756
08/12/2025, 8:24 PMrhythmic-jordan-68259
08/12/2025, 9:25 PMtall-airline-16756
08/12/2025, 9:26 PMagents.build.speech
module.
• Text and Audio Modalities: When you initialize RealtimeModel
, decide which modalities you want—like text, audio, or both. For example, use modalities=["text", "audio"]
to enable them together.
• Room Input/Output Options: You can turn text and audio inputs or outputs on or off by setting up RoomInputOptions
and RoomOutputOptions
. Here’s a quick example:
from livekit.agents.build import RoomInputOptions, RoomOutputOptions
# Enable text input
input_options = RoomInputOptions(
text_enabled=True,
)
# Enable audio output with transcription
output_options = RoomOutputOptions(
audio_enabled=True,
transcription_enabled=True,
)
• Model Parameters: Feel free to customize the voice and instructions for your audio responses by adjusting the RealtimeModel
parameters. Like this:
model = RealtimeModel(
api_key="your-api-key",
voice="alloy", # Choices: "alloy", "echo", "shimmer"
instructions="Provide concise and clear status updates.",
modalities=["text", "audio"],
)
These setups give you the flexibility to decide how your agent shares status updates—whether by text, audio, or both. If you want a hand with anything else, just give me a shout!rhythmic-jordan-68259
08/12/2025, 9:27 PMtall-airline-16756
08/12/2025, 9:28 PMgenerate_reply
method to send little updates during longer tasks. Here’s a quick example:
import asyncio
from livekit.agents import function_tool, RunContext
@function_tool()
async def perform_slow_operation(
self,
context: RunContext,
query: str,
) -> str:
async def _speak_status_update(delay: float = 0.5):
await asyncio.sleep(delay)
await context.session.generate_reply(instructions=f"""
Currently processing your request about \"{query}\".
""")
status_update_task = asyncio.create_task(_speak_status_update(0.5))
# Perform slow operation
result = await _perform_slow_operation(query)
# Cancel status update if completed before timeout
status_update_task.cancel()
return result
• "Thinking" Sounds: Another neat trick is to play some background audio so users know the agent is hard at work. Check this out:
from livekit.agents import BackgroundAudioPlayer, AudioConfig, BuiltinAudioClip
async def entrypoint(ctx: agents.JobContext):
session = AgentSession(
# ... initializations
)
await session.start(room=ctx.room)
background_audio = BackgroundAudioPlayer(
thinking_sound=[
AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING, volume=0.8),
AudioConfig(BuiltinAudioClip.KEYBOARD_TYPING2, volume=0.7),
],
)
await background_audio.start(room=ctx.room, agent_session=session)
• Preemptive Generation: You can also have a secondary, faster model whip up quick responses while the main task is still running. Here’s how:
import asyncio
from livekit.agents import Agent
class MyAgent(Agent):
def __init__(self):
super().__init__(instructions="Your instructions here.")
self.fast_llm = FastLanguageModel() # Replace with actual fast model
async def on_user_turn_completed(self, turn_ctx: ChatContext, new_message: ChatMessage):
fast_response_task = asyncio.create_task(self.generate_fast_response())
filler_response = await fast_response_task
turn_ctx.add_message(role="assistant", content=[filler_response])
async def generate_fast_response(self) -> str:
# Generate a short response using the fast model
return "Let me look into that for you."
These little tricks help make sure your users feel heard and get quick feedback while waiting for the agent to finish its work. If you want to chat more about this or need a hand setting it up, just let me know—I’m here to help!rhythmic-jordan-68259
08/12/2025, 9:37 PMtall-airline-16756
08/12/2025, 9:38 PMrhythmic-jordan-68259
08/12/2025, 10:19 PMasync def entrypoint(ctx: JobContext):
rhythmic-jordan-68259
08/12/2025, 10:24 PM