Is this possible with livekit - To make the intera...
# ask-ai
n
Is this possible with livekit - To make the interaction feel more human, it might help to include small verbal gestures or acknowledgements in between when the customer is speaking
t
Thanks for reaching out, Shrirang. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — that’s a great idea for making conversations feel more natural. Yes, you can do this with LiveKit. You can play short verbal acknowledgements or “thinking” sounds while a customer is speaking by using LiveKit’s background/on-demand audio features. A few practical options: • Use the BackgroundAudioPlayer to play small sounds (typing, short chimes, breathing, etc.). You can configure a built-in clip like
BuiltinAudioClip.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 Documentation
n
Sure. Please do
t
Great — I’ll walk you through two practical approaches with examples and best practices so you can add short verbal acknowledgements or “thinking” sounds during a LiveKit session. Which approach you pick depends on whether you want pre-recorded audio clips or short TTS phrases: • Pre-recorded clips (fast, predictable, small files — e.g., typing, chime, sigh) • TTS or pre-synthesized phrases (more flexible — “I see,” “Got it” — but may introduce slight latency) Code examples below show the typical flow: playing a short background clip and invoking on-demand playback (TTS or pre-recorded) while handling interruptions so the user’s speech isn’t cut off abruptly. 1) Play a background clip (short non-voice sound) • Use the BackgroundAudioPlayer to play short clips like typing or thinking while the customer is speaking. Keep clips short (200–1500 ms) so they feel natural. Example (pseudo-JS using LiveKit-style APIs):
Copy code
// 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):
Copy code
// 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?