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.

The voice parameter supports three formats: a simple voice name, an explicit engine/model via separate parameters, or a combined "engine.voice:model" string.

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:

  • Simple name: "en-US-Neural2-F"
  • Combined format: "elevenlabs.josh:eleven_turbo_v2_5"
  • Short name with explicit engine: "josh"
config.engine
string

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

config.fillers
Record<string, string[]>

Filler phrases keyed by category for this language.

config.speechModel
string

Speech recognition model identifier.

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

Per-function filler phrases, keyed by function name then language code.

Returns

AgentBase — Returns this for method chaining.

Examples

Simple voice

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

Explicit engine

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText('You are a helpful assistant.');
5agent.addLanguage({
6 name: 'English',
7 code: 'en-US',
8 voice: 'josh',
9 engine: 'elevenlabs',
10});
11await agent.serve();

With fillers

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText('You are a helpful assistant.');
5agent.addLanguage({
6 name: 'English',
7 code: 'en-US',
8 voice: 'rime.spore',
9 fillers: {
10 speech: ['Um...', 'Let me think...'],
11 },
12 functionFillers: {
13 get_weather: { 'en-US': ['Checking the weather...', 'One moment please...'] },
14 },
15});
16await agent.serve();