AgentsAgentBase

add_language

View as MarkdownOpen in Claude

Add a language configuration with voice settings. The agent uses these configurations to support multilingual conversations with appropriate TTS voices.

Language configurations map to the SWML ai.languages array. See the SWML languages reference for the full specification.

Write voice as "engine.voice", optionally with a ":model" suffix. A bare voice name works only alongside an explicit engine argument, because on its own it resolves against a default engine that can change.

Parameters

name
strRequired

Human-readable language name (e.g., "English", "French", "Spanish").

code
strRequired

Language code (e.g., "en-US", "fr-FR", "es-MX").

voice
strRequired

TTS voice identifier. Accepts one of three formats:

  • Engine and voice: "elevenlabs.josh"
  • Engine, voice, and model: "elevenlabs.josh:eleven_turbo_v2_5"
  • Voice name with explicit engine/model: "josh"

Always name the engine, either in the voice string or through engine. A voice name on its own — "en-US-Neural2-F" — is resolved against a default engine, and that default can change.

speech_fillers
list[str] | NoneDefaults to None

Filler phrases used during natural speech pauses (e.g., ["Um...", "Let me see..."]).

function_fillers
list[str] | NoneDefaults to None

Filler phrases spoken while executing SWAIG functions (e.g., ["One moment please...", "Looking that up..."]).

engine
str | NoneDefaults to None

Explicit TTS engine name (e.g., "elevenlabs", "rime"). Overrides the combined string format if provided.

model
str | NoneDefaults to None

Explicit TTS model name (e.g., "eleven_turbo_v2_5", "coda"). Overrides the combined string format if provided.

params
dict[str, Any] | NoneDefaults to None

Per-language params dict for engine-specific tuning and voice settings. Emitted as the language object’s params key in SWML, and only included when non-empty (e.g., {"stability": 0.5, "similarity_boost": 0.75}).

Returns

AgentBase — Returns self for method chaining.

Examples

Engine and voice (engine.voice)

from signalwire import AgentBase
agent = AgentBase(name="support", route="/support")
agent.set_prompt_text("You are a helpful assistant.")
agent.add_language("English", "en-US", "rime.spore")
agent.serve()

Explicit engine and model

from signalwire import AgentBase
agent = AgentBase(name="support", route="/support")
agent.set_prompt_text("You are a helpful assistant.")
agent.add_language(
"English", "en-US", "josh",
engine="elevenlabs",
model="eleven_turbo_v2_5"
)
agent.serve()

With fillers

from signalwire import AgentBase
agent = AgentBase(name="support", route="/support")
agent.set_prompt_text("You are a helpful assistant.")
agent.add_language(
"English", "en-US", "rime.spore",
speech_fillers=["Um...", "Let me think..."],
function_fillers=["One moment please...", "Looking that up..."]
)
agent.serve()

With per-language params

from signalwire import AgentBase
agent = AgentBase(name="support", route="/support")
agent.set_prompt_text("You are a helpful assistant.")
agent.add_language(
"English", "en-US", "josh",
engine="elevenlabs",
params={"stability": 0.5, "similarity_boost": 0.75}
)
agent.serve()