how can an change an agent's voice or speed during...
# ask-ai
n
how can an change an agent's voice or speed during the call (elevenlabs tts)?
t
Thanks for reaching out, Francisco. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help with that. You're asking how to change an agent’s voice or speech speed during a call when using ElevenLabs TTS. Here’s how to do that. What to do • Use the agent session’s TTS instance method
update_options
to change voice and speed while the session is running. • Changes take effect on the next utterance (you do not need to restart the session). Key parameters • `voice_id`: the ElevenLabs voice identifier you want the agent to use. • `speed`: speech speed multiplier in the range
0.5
to
2.0
(values >1.0 speed up speech, <1.0 slow it down). Example (Python)
Copy code
# Update voice and speed during the call
session.tts.update_options(
    voice_id="new_voice_id",
    speed=1.5
)
Notes and limitations • The
speed
parameter is supported by the ElevenLabs plugin and applies to subsequent utterances. • Custom or cloned voices are not supported via LiveKit Inference; to use those you must use the ElevenLabs plugin with your own ElevenLabs account. If you want, tell me: • Which voice_id you plan to switch to (or what kind of voice you want), and • Whether you want the speed change to be temporary for a single utterance or persist for the rest of the call. I can then suggest exact code snippets or show how to trigger the change at a particular point in your call flow. Sources: ElevenLabs TTS plugin guide | LiveKit Documentation | ElevenLabs TTS | LiveKit Documentation
n
what about node js?
t
Thanks — you're asking how to change an agent’s ElevenLabs TTS voice or speaking speed during a call in Node.js. You can update the TTS options at runtime using the session TTS instance’s
update_options
method; changes take effect on the next utterance. Node.js example
Copy code
// assuming you're using the ElevenLabs TTS plugin and have access to the agent session
class MyAgent extends voice.Agent {
  async switchVoiceAndSpeed() {
    // Update voice ID and adjust speed for next utterance
    this.session.tts?.update_options({
      voice_id: 'EXAVITQu4vr4xnSDxMaL', // new ElevenLabs voice ID
      speed: 1.2,                      // 1.0 = normal, 0.5-2.0 supported range
      stability: 0.8,                  // optional ElevenLabs voice params
      similarity_boost: 0.9            // optional
    });
  }
}
Key points • Use
voice_id
to select the ElevenLabs voice. • Use
speed
(e.g., 0.5–2.0) to slow down or speed up speech; values >1.0 increase speed. • Other ElevenLabs parameters (like
stability
,
similarity_boost
,
style
) can also be provided. • Changes apply to subsequent utterances — they do not interrupt the current speech. If you want, tell me: • The voice_id you plan to use, or the kind of voice (male/female, tone) you want, and • Whether the change should be one-off (next utterance) or persistent for the session. I can provide a complete runnable snippet showing how to trigger this from an event or tool in your agent flow. Sources: ElevenLabs TTS plugin guide | LiveKit Documentation
n
what are the options to access the agent session? the other participant updating its localParticipant parameters?
t
Thanks — I’m responding to your question about how to access the AgentSession (so you can update ElevenLabs TTS voice/speed) and whether changing another participant’s
localParticipant
parameters is a valid approach. Short answer • Access the AgentSession directly (recommended): from inside an Agent class (
this.session
/
self.session
), from the RTC session entrypoint before/after
session.start()
, or from a tool lifecycle via the
RunContext
(
context.session
). • No — updating another participant’s
localParticipant
parameters is not a valid way to change the agent’s TTS settings. Use the session’s TTS API instead (e.g.,
session.tts.update_options()
). How to access AgentSession (options) • From an Agent subclass ◦ Inside your agent logic you can reference the session directly:
this.session
(Node) or
self.session
(Python). ◦ This is the most direct place to call
this.session.tts.update_options(...)
. • From the RTC session entrypoint ◦ The AgentSession is created in the rtc_session entrypoint; you can keep a reference when you instantiate it and use it before/after
session.start()
. • From a function tool or lifecycle hook ◦ Tools receive a
RunContext
(or similar) that exposes
context.session
, which is the current AgentSession. • From global job context ◦ The framework exposes job-level context (AsyncLocalStorage). You can access the job context to reach session-related objects when appropriate. Why not use
localParticipant
updates •
localParticipant
is for room-level participant state (publishing tracks, metadata/attributes) and is meant for client/frontend synchronization. • The AgentSession controls the AI pipeline (STT, LLM, TTS). Updating participant metadata will not change the agent’s internal TTS configuration. • To change voice or speed reliably, call the TTS API on the session:
session.tts.update_options({ voice_id: "...", speed: 1.2 })
. Changes take effect on the next utterance. If you want, I can: • Show a concrete Node.js example that updates
this.session.tts.update_options()
from a function tool or event handler. • Help you decide where to trigger the update in your call flow (e.g., on a user command, on a specific intent, or on a UI action), and provide the exact snippet for that case. Which would help most: a short runnable snippet inside an Agent method, or an example showing how to trigger it from the frontend via metadata/command? Sources: Agent session | LiveKit Documentation | Build a multilingual voice agent that automatically switches languages | Li... | Tool definition and use | LiveKit Documentation | Agents (Node.js) | livekit/livekit_composite | DeepWiki | Pipeline nodes and hooks | LiveKit Documentation