nutritious-vase-44413
02/16/2026, 9:04 AMtall-airline-16756
02/16/2026, 9:04 AMtall-airline-16756
02/16/2026, 9:04 AMBuiltinAudioClip.KEYBOARD_TYPING or supply custom audio to simulate the agent being active.
• Emit short verbal acknowledgements (e.g., “I see”, “Got it”) by calling session.say() with pre-synthesized audio or TTS audio. This can be played even while the participant is speaking.
• Configure an automatic “thinking” sound during longer processing or tool calls by setting thinking_sound in the BackgroundAudioPlayer so the sound plays while the system is busy.
• Handle interruptions smoothly: you can stop or fade out the acknowledgement sound if the user continues speaking, so transitions feel natural and non-intrusive.
If you’d like, I can help with next steps:
• Provide a short code example for playing a background clip or invoking session.say().
• Suggest best practices for timing/volume to avoid interrupting the user.
• Help design a list of short acknowledgement sounds or phrasing that feel natural for your use case.
Which would you prefer next?
Sources: Agent speech and audio | LiveKit Documentationnutritious-vase-44413
02/16/2026, 9:06 AMtall-airline-16756
02/16/2026, 9:06 AM// 1) Initialize BackgroundAudioPlayer for the session
const bgPlayer = new BackgroundAudioPlayer(session);
// 2) Load or reference a built-in or uploaded clip
// Example: BuiltinAudioClip.KEYBOARD_TYPING or your uploaded 'thinking_short.mp3'
await bgPlayer.loadClip('thinking_short.mp3');
// 3) Play while processing or when you detect a pause
bgPlayer.play({
loop: false,
volume: 0.6, // slightly lower than voice level
duckOnSpeak: true, // lower background volume automatically when other speech starts
});
// 4) Stop or fade when the user resumes speaking or when done
bgPlayer.stop({ fade: 150 }); // fade-out over 150ms for smooth transition
Practical tips for background clips:
• Volume: set ~40–70% of voice volume so it’s clearly audible but not distracting.
• Length: keep sounds short (<1s) or loop very subtly.
• Ducking: enable ducking so the sound lowers automatically when someone speaks.
• Fade: use short fades (100–300 ms) to avoid abrupt on/off artifacts.
2) Play short voice acknowledgements (TTS or pre-synthesized audio)
• Use session.say() or on-demand audio playback to speak short phrases like “I see,” “Got it,” or “One sec.” Pre-synthesize phrases if you need near-zero latency.
Example (pseudo-JS mixing TTS and pre-recorded):
// Option A: Play pre-synthesized audio file
await session.playAudio('got_it_short.mp3', {
interrupt: true, // allow this audio to interrupt background clips
duckParticipants: true,
volume: 0.9,
});
// Option B: Trigger TTS (if supported) for dynamic phrases
await session.say({
text: 'Got it.',
voice: 'friendly_male',
volume: 0.95,
allowInterrupt: true,
});
Interruption & user-resume handling:
• If the user starts speaking while the acknowledgement plays, immediately stop or duck the audio.
• Use voice activity detection (VAD) or LiveKit’s speaking state events to detect when a participant is speaking and to trigger stopping/ducking.
Example logic:
1. Detect user speaking (onParticipantSpeaking event).
2. If user is speaking and bgPlayer is playing: fade or stop bgPlayer immediately.
3. If you need to acknowledge during a long pause, start bgPlayer; when user resumes, stop it.
3) Best practices for timing and UX
• Only use small acknowledgements sparingly — too many will feel robotic.
• Space them: no more than 1–2 short acknowledgements per extended silence or wait.
• Tailor semantics:
◦ Use non-verbal cues (typing, hum) for “I’m working on that”.
◦ Use short verbal cues (“I see,” “One moment”) when confirming you heard something.
• Respect privacy and clarity: ensure sounds don’t mask the customer’s speech; duck or stop when customer speaks.
• Test in realistic network/latency conditions to ensure timing remains natural.
4) Implementation checklist
• Choose clip types (pre-recorded vs TTS).
• Define triggers: VAD pause detection, tool-call start/finish, long processing.
• Implement ducking/interruption rules.
• Add volume and fade controls (configurable per environment).
• User test and iterate for naturalness.
If you’d like, I can:
• Provide a concrete code sample targeted to your SDK (JS, TypeScript, or another language).
• Suggest a short library of good acknowledgement clips and exact timing/volume values tuned for voice calls.
• Help you design event triggers (VAD thresholds, pause duration) for your use case.
Which SDK/language are you using (browser JS, React Native, server-side) and do you prefer pre-recorded clips or TTS?