Skip to navigation
AgentsAgentBase

set_default_voice

View as MarkdownOpen in Claude

Set a voice for every voice field the agent leaves empty: the agent’s own voice, a language with no voice, and a multilingual language with no voice. A voice the agent sets itself, with set_agent_voice(), add_language(), or set_multilingual(), takes precedence.

The SDK sets the SWML variable default_voice with a set verb just before the ai verb.

Parameters

voice
str | Sequence[str] | Mapping[str, str | Sequence[str]] | NoneRequired

One of:

  • One voice as engine.voice:model.
  • A list of up to 8 voices. The first speaks and the rest are tried in order when it fails.
  • A mapping from language codes to a voice or a list, with a "default" entry for every other language. The platform matches a language by its exact code, then by its base language (es for es-MX), then by "default". When the agent has no multilingual languages of its own, the mapping’s languages become them.
  • None clears the setting.

Returns

AgentBase — Returns self for method chaining.

Raises

ValueError for an empty voice, more than 8 voices, an empty mapping, or a mapping key that isn’t a non-empty string.

Example

from signalwire import AgentBase
agent = AgentBase(name="intake", route="/intake")
agent.prompt_add_section("Role", "You take new patient details.")
agent.set_default_voice({"es": "elevenlabs.lucia", "default": "rime.spore"})
agent.serve()
{"main": [
{"answer": {}},
{"set": {"default_voice": {"es": "elevenlabs.lucia", "default": "rime.spore"}}},
{"ai": {"...": "..."}}
]}