Skip to navigation

addLanguage

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 field, because on its own it resolves against a default engine that can change.

Parameters

config
LanguageConfigRequired

A language configuration object with the following fields:

config.name
stringRequired

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

config.code
stringRequired

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

config.voice
string

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: "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.

config.engine
string

Explicit TTS engine name (e.g., "elevenlabs", "rime").

config.model
string

Explicit TTS model identifier (e.g., "mistv2", "eleven_turbo_v2_5").

config.speechFillers
string[]

Phrases the AI can say to fill a pause in speech. Rendered as speech_fillers.

config.functionFillers
string[] | Record<string, Record<string, string[]>>

Phrases the AI says while a function runs. Rendered as function_fillers. An object keyed by function name then language code is flattened into one list, with a warning; for fillers per tool, use the tool’s own fillers option.

When both speech and function fillers are set, the language renders speech_fillers and function_fillers. When only one is set, it renders as the older fillers list.

config.fillers
string[] | Record<string, string[]>

Filler phrases for both speech and functions, the older single fillers list. Used as speechFillers when that isn’t set. An object keyed by category is flattened into one list, with a warning; pass a string array instead.

config.speechModel
string

Speech recognition model identifier.

config.params
Record<string, unknown>

Optional per-language params dictionary for engine-specific tuning (e.g. voice settings). Only emitted into the SWML document when non-empty, so existing entries stay byte-identical when omitted. Can also be set or updated later via setLanguageParams().

Returns

AgentBase — Returns this for method chaining.

Examples

Engine and voice (engine.voice)

import { AgentBase } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'support', route: '/support' });
agent.setPromptText('You are a helpful assistant.');
agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
await agent.serve();

Explicit engine

import { AgentBase } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'support', route: '/support' });
agent.setPromptText('You are a helpful assistant.');
agent.addLanguage({
name: 'English',
code: 'en-US',
voice: 'josh',
engine: 'elevenlabs',
});
await agent.serve();

With fillers

import { AgentBase } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'support', route: '/support' });
agent.setPromptText('You are a helpful assistant.');
agent.addLanguage({
name: 'English',
code: 'en-US',
voice: 'rime.spore',
speechFillers: ['Um...', 'Let me think...'],
functionFillers: ['Checking on that...', 'One moment please...'],
});
await agent.serve();