Skip to navigation
AgentsAgentBase

set_fallback_voice

View as MarkdownOpen in Claude

Set the voices the platform tries once a language’s voices, or the agent’s own voice, have all failed, before its own last resort. The SDK sends them as the fallback_voice key of the SWML ai verb.

The platform tries an agent’s voices in this order: the language’s own voice or voice list from add_language(), the agent’s voice from set_agent_voice() for a language with none, this list, and the platform’s own last resort.

Parameters

voice
str | Sequence[str] | NoneRequired

One voice as engine.voice:model, or a list of up to 8, tried in order. A one-item list stays a list. None clears the setting.

Returns

AgentBase — Returns self for method chaining.

Raises

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

Example

from signalwire import AgentBase
agent = AgentBase(name="sales", route="/sales")
agent.prompt_add_section("Role", "You answer sales calls.")
agent.set_agent_voice(["rime.spore:arcana", "elevenlabs.josh"])
agent.set_fallback_voice("cartesia.kurt")
agent.serve()
{"ai": {
"prompt": {"...": "..."},
"params": {},
"voice": ["rime.spore:arcana", "elevenlabs.josh"],
"fallback_voice": "cartesia.kurt"
}}