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
Optional[list[str]]

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

function_fillers
Optional[list[str]]

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

engine
Optional[str]

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

model
Optional[str]

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

params
Optional[dict[str, Any]]Defaults 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)

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

Explicit engine and model

1from signalwire import AgentBase
2
3agent = AgentBase(name="support", route="/support")
4agent.set_prompt_text("You are a helpful assistant.")
5agent.add_language(
6 "English", "en-US", "josh",
7 engine="elevenlabs",
8 model="eleven_turbo_v2_5"
9)
10agent.serve()

With fillers

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

With per-language params

1from signalwire import AgentBase
2
3agent = AgentBase(name="support", route="/support")
4agent.set_prompt_text("You are a helpful assistant.")
5agent.add_language(
6 "English", "en-US", "josh",
7 engine="elevenlabs",
8 params={"stability": 0.5, "similarity_boost": 0.75}
9)
10agent.serve()