Build multilingual voice applications
Bayview Taxi’s riders don’t all speak English, and some switch languages partway through a call. Ada, Bayview’s AI dispatcher, can follow them: she hears which language each caller speaks and answers in it, in a voice you choose for that language. Start by choosing the right option from the seven SignalWire offers, then give Ada a voice per language and call her to hear the switch. After that, tune when she switches, translate her fillers, and offer a fixed set of languages instead.
Pick the right option for multilingual calls
Seven settings affect the language of a call. They live in different places and don’t do the same job, so choose by what the caller should experience:
ai.multilingual and ai.languages are mutually exclusive. When an agent sets both, SignalWire
uses multilingual and ignores languages. Language handling is switched on by setting one of the
two, which is why languages_enabled changes nothing. The auto key works with either.
Prepare for multilingual calls
This guide extends the agent from the AI quickstart. Have these ready:
- The quickstart’s public URL, its External URL resource, and the phone number assigned to it.
- A phone to call that number from.
- Enough Spanish to say a short sentence. Any two languages from the list below work if you change the codes and voices to match.
ai.multilingual runs speech recognition in code-switching mode, which by default covers English,
Spanish, French, German, Hindi, Russian, Portuguese, Japanese, Italian, and Dutch. Use the
two-letter codes en, es, fr, de, hi, ru, pt, ja, it, and nl.
Answer each caller in their own language
Give Ada a multilingual configuration with one voice per language. The entry whose language is
default is the voice she opens the call with, and the one she uses for any language without an
entry of its own. Here it is English, with a Spanish voice beside it:
Run the Server SDK sample the way the quickstart runs agent.py, on the same port and behind the
same tunnel, so the number you already assigned reaches Ada. To serve the SWML by hand instead,
replace the quickstart’s swml.json with the JSON above.
Speech recognition reports the language of every caller turn. When it changes, SignalWire tells
the model which language the caller is now speaking and switches to that language’s voice, so the
prompt doesn’t need to mention languages at all. Name the engine in every voice string, as
rime.spore:coda does: a bare voice name resolves against a default engine that can change. The
text-to-speech guide lists the voices each engine offers.
If one voice can speak every language you allow, such as an ElevenLabs voice on a multilingual
model, give multilingual a single default entry. Ada then keeps the same voice all call, and
only her language changes.
Call Ada and switch languages
Call your number and speak to Ada in English. She answers in English, in the Rime voice. Then say a full sentence in Spanish, such as “Necesito un taxi al aeropuerto, por favor.” Ada answers in Spanish, and her voice changes to the Azure voice. Switch back with a sentence in English, and she follows you back.
If the call doesn’t go that way, match what you hear:
- Ada answers only in English, in a voice you didn’t configure. Multilingual mode didn’t
start, and the agent fell back to a single English voice. A code in
allowedor inlanguagesisn’t one that speech recognition supports, or thedefaultentry has novoice. Check the codes against the list in Prepare for multilingual calls. - A one-word answer like “Sí” doesn’t switch her. That’s by design: a single word is often the same in several languages, so Ada waits for at least two. See Control when Ada switches languages.
- Ada switches to Spanish but keeps the English voice. The Spanish entry has no
voice, or itslanguageisn’tes, so thedefaultentry speaks Spanish too. - Ada doesn’t follow you into a third language. It isn’t in
allowed. She hears what you said and answers it, but stays in the language she was speaking.
Control when Ada switches languages
Three properties decide when Ada changes language. All three are on the
multilingual reference.
allowedlists the languages she may switch into. A caller who speaks another language is still heard, but Ada keeps her current language. Leaveallowedout to let her follow a caller into any language speech recognition detects.min_switch_wordsis how many words a turn needs before it can switch the language,2by default. Set it to1when callers often answer in single words and those words aren’t shared between your languages. A turn that speech recognition isn’t confident about doesn’t switch the language either, however long it is.start_languageis the language Ada opens the call in, before the caller has said anything,enby default. For a line that mostly serves Spanish speakers, set it toesand make the Spanish voice thedefaultentry.
Translate fillers into the caller’s language
Fillers are the short phrases Ada says to cover a pause, such as “One moment while I check.” With
several languages, each filler has to exist in each of them. The auto key saves you writing them
all: put phrases under auto in any language, and when Ada needs a filler in a language with no
entry of its own, SignalWire translates the auto phrases into it. The translation runs the first
time each language needs it and is reused for the rest of the call.
Under multilingual, fillers and function_fillers accept a plain array, which is treated as
auto. This change to the first sample gives Ada a filler for whenever one of her SWAIG functions
runs, said in the caller’s language:
The same key works in the language-keyed filler maps on a SWAIG function, such as its
fillers, with or without multilingual. Ada looks for an entry matching the
current language first, then auto, then default, so you can write the languages that matter
most by hand and let auto cover the rest. Under ai.languages, the current language is the
active entry’s code. An entry whose code is multi never has its fillers translated, because
multi doesn’t name a language. Filler language codes covers the lookup in full.
turn_fillers, the short backchannels Ada plays while a caller is still talking, are never
translated. Write them per language.
Offer a fixed set of languages instead
When each call stays in one language, ai.languages is the simpler choice. List one entry per
language, each with a name, a speech recognition code, and a voice. Ada opens in the first
entry’s language and is told to switch to another listed language only when the caller asks for
it. When she switches, her voice changes and speech recognition starts listening for the new
entry’s code.
To test it, replace the multilingual configuration in the first sample with these lines, call Ada, and ask in English whether she can speak Spanish. She answers in Spanish, in the Azure voice, and keeps to Spanish until you ask to change back.
Setting one entry’s code to multi makes speech recognition transcribe whichever of its
code-switching languages the caller speaks, but Ada still answers in that entry’s single voice, and
she doesn’t move to another entry. Use it on an agent with one languages entry, when Ada should
understand callers who mix languages but reply in one. multi needs Deepgram speech recognition,
the default; the code reference lists what each Deepgram model covers.