# 04 Polyglot

> Deepgram workshops › Build a voice agent › Mission 04
> Web version: https://workshops.deepgram.com/voice-agent/polyglot
> 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/polyglot/switch.md)
- [Make the voice follow](https://workshops.deepgram.com/voice-agent/polyglot/voice.md)

## Switch mid-conversation

### Talk in two languages

**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._

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

### Change the 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._

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

### Hard mode

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

**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 hears every language in the picker and 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, 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, so 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, a failed swap), 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; 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

### Hear it

**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._

**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 (the **Settings JSON** tab shows it), so the agent still answers in your second language, read by the voice you picked in Settings, and this checkpoint checks your Voice language setting. With it on, Voice language picks a voice made for that language, and the list 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.
