> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# set_default_voice

> Set a voice, or a voice per language, for every voice field the agent leaves empty.

[ref-agentbase]: /docs/server-sdks/reference/python/agents/agent-base

[set-agent-voice]: /docs/server-sdks/reference/python/agents/agent-base/set-agent-voice

[add-language]: /docs/server-sdks/reference/python/agents/agent-base/add-language

[set-multilingual]: /docs/server-sdks/reference/python/agents/agent-base/set-multilingual

[swml-set]: /docs/swml/reference/calling/set

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()`][set-agent-voice],
[`add_language()`][add-language], or [`set_multilingual()`][set-multilingual], takes
precedence.

The SDK sets the SWML variable `default_voice` with a [`set`][swml-set] verb just before
the `ai` verb.

## Parameters

**`voice`** `str | Sequence[str] | Mapping[str, str | Sequence[str]] | None` — required

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`][ref-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

```python {5}
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()
```

```json
{"main": [
  {"answer": {}},
  {"set": {"default_voice": {"es": "elevenlabs.lucia", "default": "rime.spore"}}},
  {"ai": {"...": "..."}}
]}
```