# 04 Polyglot

> Deepgram workshops › Build a voice agent › Mission 04
> Web version: https://workshops.deepgram.com/voice-agent/multilingual
> About 25 min (estimate). Check it: `make check 04` (offline, no key).

Switch languages mid-conversation and it follows.

- [Switch mid-conversation](https://workshops.deepgram.com/voice-agent/multilingual/switch.md)
- [Make the voice follow](https://workshops.deepgram.com/voice-agent/multilingual/voice.md)

## Switch mid-conversation

### Talk in two languages

**Goal:** Say a line in English, then one in Spanish, and hear the agent follow you into the second language.

**Language hints** tell the listener which languages to expect. The picker starts with English and Spanish.

**Do:** Tap **Start the agent**. Say a line in English, wait for the reply, then say your next line in Spanish.

**Listen for:** the reply in Spanish.

_On the web page, this step has the Settings panel; in your own code the same settings are in the start file._

**Phrases to try**

One short, polite line per language.

| Language | Try saying |
|---|---|
| English | Hello, could you help me find the schedule, please? |
| Spanish | Hola, ¿me puede ayudar con el horario, por favor? |
| French | Bonjour, pouvez-vous m’aider avec le programme, s’il vous plaît ? |
| German | Hallo, können Sie mir bitte mit dem Programm helfen? |
| Hindi | नमस्ते, क्या आप मेरी मदद कर सकते हैं? |
| Russian | Здравствуйте, вы можете мне помочь, пожалуйста? |
| Portuguese | Olá, você pode me ajudar com a programação, por favor? |
| Japanese | こんにちは、手伝っていただけますか？ |
| Italian | Buongiorno, mi può aiutare con il programma, per favore? |
| Dutch | Hallo, kunt u mij alstublieft helpen met het programma? |

_On the web page, this step has the agent console: talk or type to the agent there, or run the same mission in your own code._

**You should see:** the agent reply in Spanish, in the same conversation. If it answers in English, check that Spanish is in **Language hints**, tap **Reconnect and apply**, and try a longer sentence.

**Check:** It followed you into a second language.

### Change your language hints

**Do:** Swap Spanish in **Language hints** for another language, tap **Reconnect and apply**, and run it again.

_On the web page, this step shows the code panel with the matching code._

**You should see:** the check pass once your hints differ from the default pair, English and Spanish. If they're still the default, pick a different pair, tap **Reconnect and apply**, and say something.

**Check:** You told it which languages to expect.

### Hard mode: switch inside one sentence

**Do:** **Hard mode.** Start a sentence in one language and finish it in the other, out loud.

**You should see:** the check pass, with both languages listed for that one turn. Only the listener's own tag counts, so a typed line can't pass this one. Keep both languages in **Language hints**.

**Check:** Hard mode: two languages in one turn. (Optional.)

Take it home: [Python](https://github.com/deepgram-devs/voice-agent-workshop/blob/main/python/missions/04-polyglot/start.py) or [TypeScript](https://github.com/deepgram-devs/voice-agent-workshop/blob/main/typescript/missions/04-polyglot/start.ts).

**How it works**

With {{name.multi}} on, one listener (the speech-to-text model) hears every language in the picker. It tags each turn with the languages it heard, most words first. **Language hints** tell it which to expect. With two hinted, it commits sooner and wanders less between close pairs like Spanish and Portuguese.

The prompt already says to answer in whatever language you just used. Each turn also carries the hints that were active, so you can compare.

When the check runs, the card lists the tag for every turn ("Languages per turn: English; Spanish."). The agent answers each turn in one language, so a switch between turns is the main test. A switch inside a turn is hard mode, read from the listener's own tag.

**In code:** hints are `language_hints`, a list on `agent.listen.provider` in the Settings message. On the standalone listener at `/v2/listen`, it's the `language_hint` query parameter, once per language. Both work only with the multilingual listen model.

The code panel shows the whole loop: hints on the listener, then an `UpdateSpeak` when a turn comes back in a new language. The new voice starts on the agent's next reply.

Both sample voices are Aura-2 text-to-speech voices, one per language, so the swap runs the same on your own key or a workshop token. If the server can't apply a voice, it answers `Error` and ends the call. The snippets print one clear line and stop.

More in the docs: [Configure the Voice Agent](https://developers.deepgram.com/docs/configure-voice-agent), [Language prompting](https://developers.deepgram.com/docs/flux/language-prompting), [ConversationText](https://developers.deepgram.com/docs/voice-agent-conversation-text), [UpdateSpeak](https://developers.deepgram.com/docs/voice-agent-update-speak).

**Take it further:** say a line in a language you didn't hint, and see whether it follows, hesitates, or holds the pair. Then switch back and forth three times and watch the per-turn tags.

The attendee project's Mission 04 has three TODOs: hints, the voice swap, and a failed swap. It also has an offline check (`make check 04`) and Aura-2 voices for seven languages. For a simpler starter, the [todo voice agent workshop](https://github.com/deepgram-devs/todo-voice-agent-workshop) builds one agent step by step.

**Typing works too.** A typed line carries no listener tag, so the card reads its language from the text and says so. A reply that only repeats your words back doesn't count, because the check reads the agent's own words.

**In production**

- **Watch:** the share of user turns whose first `languages` entry isn't in `languages_hinted`, and every `Error` after an `UpdateSpeak`.
- **Start with:** hints for the two or three languages your callers actually use, and a voice for each of them. 
- **Read:** [Language prompting](https://developers.deepgram.com/docs/flux/language-prompting).

## Make the voice follow

### Set the voice language and listen

**Goal:** Set a voice language, speak in your second language, and hear the reply.

**Do:** Set **Voice language** to your second language, tap **Reconnect and apply**, and say a line in it.

**Listen for:** the reply in your second language.

_On the web page, this step has the Settings panel; in your own code the same settings are in the start file._

_On the web page, this step has the agent console: talk or type to the agent there, or run the same mission in your own code._

**You should see:** the agent answer in your second language. If the check says Voice language is still on the default, set it to your second language. Then tap **Reconnect and apply** and get it to answer.

**Check:** You picked a voice language. (Optional.)

**What you tuned:** the hearing layer. One listener follows every language you speak, and the reply follows you too.

**How it works**

{{name.multiVoice}} is off here, and the **Settings JSON** tab shows it. The agent still answers in your second language, read by the voice you picked in Settings. This checkpoint checks your Voice language setting.

With {{name.multiVoice}} on, Voice language picks a voice made for that language. The list then shows only languages with a voice, so it can be shorter than Language hints.

Mystery guest takes any agent from this workshop, this one included.
