> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Multilingual Transcription

export const ModelBadges = ({models}) => {
  return <div className="flex flex-wrap gap-2 -mt-3 mb-3 not-prose">
      {models.map(model => <span key={model} className="inline-flex items-center rounded-full bg-green-500/15 px-2.5 py-0.5 text-xs font-mono text-green-700 dark:text-green-400 ring-1 ring-inset ring-green-500/30">
          {model}
        </span>)}
    </div>;
};

export const AudioPlayer = ({src, type = "audio/mpeg", fallbackText = "Your browser does not support the audio element."}) => {
  return <audio controls style={{
    width: "100%"
  }}>
      <source src={src} type={type} />
      {fallbackText} <a href={src}>Download the audio</a>.
    </audio>;
};

<ModelBadges models={["universal-3-5-pro"]} />

Transcribe live audio in any supported language, or several at once, with native code switching.

Universal-3.5 Pro Streaming is multilingual by default. It follows speakers as they shift mid-sentence between languages like English and Spanish, French, Hindi or Mandarin, preserving exactly what was said without translating everything into a single language. No configuration is required.

Hear what code switching sounds like, and how it's transcribed.

##### **English \<> French**

<AudioPlayer src="https://assembly.ai/code-switching-1" type="audio/wav" />

```txt theme={null}
I said something like, j'ai dit à mes étudiants que it's time to really pay attention to what the idea of code-switching is.
```

##### **English \<> Hindi**

<AudioPlayer src="https://assembly.ai/code-switching-2" type="audio/wav" />

```txt theme={null}
मेरा रुकने का तो बहुत मन है, but I have an exam to give tomorrow.
```

##### **English \<> Mandarin**

<AudioPlayer src="https://assembly.ai/code-switching-3" type="audio/wav" />

```txt theme={null}
But this sentence, 我父母不工作了, you can see the 了 at the end of the sentence indicates that the situation now, my parents don't work, is different from what it was before.
```

## Quickstart

Code switching is on by default. Open a streaming session with no language parameters and the model code-switches natively across all supported languages.

<Tabs>
  <Tab language="python" title="Python" default>
    ```python theme={null}
    CONNECTION_PARAMS = {
        "sample_rate": 16000,
        "speech_model": "universal-3-5-pro",
    }
    ```
  </Tab>

  <Tab language="python-sdk" title="Python SDK">
    ```python theme={null}
    client.connect(
        StreamingParameters(
            sample_rate=16000,
            speech_model="universal-3-5-pro",
        )
    )
    ```
  </Tab>

  <Tab language="javascript" title="Javascript">
    ```javascript theme={null}
    const CONNECTION_PARAMS = {
      sample_rate: 16000,
      speech_model: "universal-3-5-pro",
    };
    ```
  </Tab>

  <Tab language="javascript-sdk" title="JavaScript SDK">
    ```javascript theme={null}
    const transcriber = client.streaming.transcriber({
      sampleRate: 16_000,
      speechModel: "universal-3-5-pro",
    });
    ```
  </Tab>
</Tabs>

## Steering toward known languages

When you know which languages a session will use, pass the `language_codes` connection parameter to steer the model toward them and improve language accuracy.

* For a **known subset**, pass the codes you expect (for example, `["en", "es"]`). The model still code-switches, but heavily biased to the languages you list.
* For a **monolingual session**, pass a single-element list (for example, `["es"]`).
* For **full multilingual**, omit `language_codes` to keep native code switching across all supported languages.

Set the `language_codes` connection parameter when you open the WebSocket.

<Tabs>
  <Tab language="python" title="Python" default>
    ```python theme={null}
    CONNECTION_PARAMS = {
        "sample_rate": 16000,
        "speech_model": "universal-3-5-pro",
        "language_codes": ["en", "es"],
    }
    ```
  </Tab>

  <Tab language="python-sdk" title="Python SDK">
    ```python theme={null}
    client.connect(
        StreamingParameters(
            sample_rate=16000,
            speech_model="universal-3-5-pro",
            language_codes=["en", "es"],
        )
    )
    ```
  </Tab>

  <Tab language="javascript" title="Javascript">
    ```javascript theme={null}
    const CONNECTION_PARAMS = {
      sample_rate: 16000,
      speech_model: "universal-3-5-pro",
      language_codes: ["en", "es"],
    };
    ```
  </Tab>

  <Tab language="javascript-sdk" title="JavaScript SDK">
    ```javascript theme={null}
    const transcriber = client.streaming.transcriber({
      sampleRate: 16_000,
      speechModel: "universal-3-5-pro",
      languageCodes: ["en", "es"],
    });
    ```
  </Tab>
</Tabs>

<Tip>
  **Describing languages in a contextual prompt**

  You can also name the expected languages in natural language as part of a contextual prompt (for example, `Multilingual conversation in English, Spanish, and German.`), but `language_codes` is the best-supported way to select languages. See [Prompting and keyterms](/streaming/prompting-and-keyterms#specifying-the-language).
</Tip>

## Supported languages

Universal-3.5 Pro Streaming code-switches across 18 languages.

| Language   | Code | Language   | Code |
| ---------- | ---- | ---------- | ---- |
| English    | `en` | Danish     | `da` |
| Spanish    | `es` | Finnish    | `fi` |
| French     | `fr` | Hindi      | `hi` |
| German     | `de` | Vietnamese | `vi` |
| Italian    | `it` | Arabic     | `ar` |
| Portuguese | `pt` | Hebrew     | `he` |
| Turkish    | `tr` | Japanese   | `ja` |
| Dutch      | `nl` | Mandarin   | `zh` |
| Swedish    | `sv` | Norwegian  | `no` |

## Detecting the spoken language

Set the `language_detection` connection parameter to `true` to have each turn report which language was spoken. Turn messages then include `language_code` and `language_confidence` (a float between `0` and `1`) fields, populated when an utterance is complete or the turn is final.

```json theme={null}
{
  "type": "Turn",
  "end_of_turn": true,
  "transcript": "¿Puedo pagar la factura por teléfono?",
  "language_code": "es",
  "language_confidence": 0.92
}
```

`language_detection` only controls reporting and doesn't change how the model transcribes. It's available on Universal-3.5 Pro Streaming and Universal-Streaming Multilingual.

<Tabs>
  <Tab language="python" title="Python" default>
    ```python theme={null}
    CONNECTION_PARAMS = {
        "sample_rate": 16000,
        "speech_model": "universal-3-5-pro",
        "language_detection": True,
    }
    ```
  </Tab>

  <Tab language="python-sdk" title="Python SDK">
    ```python theme={null}
    client.connect(
        StreamingParameters(
            sample_rate=16000,
            speech_model="universal-3-5-pro",
            language_detection=True,
        )
    )
    ```
  </Tab>

  <Tab language="javascript" title="Javascript">
    ```javascript theme={null}
    const CONNECTION_PARAMS = {
      sample_rate: 16000,
      speech_model: "universal-3-5-pro",
      language_detection: true,
    };
    ```
  </Tab>

  <Tab language="javascript-sdk" title="JavaScript SDK">
    ```javascript theme={null}
    const transcriber = client.streaming.transcriber({
      sampleRate: 16_000,
      speechModel: "universal-3-5-pro",
      languageDetection: true,
    });
    ```
  </Tab>
</Tabs>

## Updating languages mid-stream

`language_codes` can be updated during an active session without reconnecting. This is useful when a voice agent detects the caller's language, or when a conversation is handed off to a speaker of another language. Send an `UpdateConfiguration` message with the new values. The change takes effect from the next turn.

<Tabs>
  <Tab language="python" title="Python" default>
    ```python theme={null}
    # Steer transcription toward new languages
    websocket.send('{"type": "UpdateConfiguration", "language_codes": ["en", "fr"]}')

    # Clear steering and return to native code switching
    websocket.send('{"type": "UpdateConfiguration", "language_codes": []}')
    ```
  </Tab>

  <Tab language="python-sdk" title="Python SDK">
    ```python theme={null}
    # Steer transcription toward new languages
    client.update_configuration(language_codes=["en", "fr"])

    # Clear steering and return to native code switching
    client.update_configuration(language_codes=[])
    ```
  </Tab>

  <Tab language="javascript" title="Javascript">
    ```javascript theme={null}
    // Steer transcription toward new languages
    websocket.send(
      '{"type": "UpdateConfiguration", "language_codes": ["en", "fr"]}'
    );

    // Clear steering and return to native code switching
    websocket.send('{"type": "UpdateConfiguration", "language_codes": []}');
    ```
  </Tab>

  <Tab language="javascript-sdk" title="JavaScript SDK">
    ```javascript theme={null}
    // Steer transcription toward new languages
    transcriber.updateConfiguration({ languageCodes: ["en", "fr"] });

    // Clear steering and return to native code switching
    transcriber.updateConfiguration({ languageCodes: [] });
    ```
  </Tab>
</Tabs>

See [Updating configuration mid-stream](/streaming/updating-configuration-mid-stream) for the full list of parameters you can update mid-stream.

## Other streaming models

Universal-3.5 Pro Streaming is the only streaming model with native (mid-sentence) code switching. The other streaming models handle languages differently.

| Model                            | Languages                          | Code switching       |
| -------------------------------- | ---------------------------------- | -------------------- |
| Universal-3.5 Pro Streaming      | 18 languages (see above)           | Native, mid-sentence |
| Universal-Streaming Multilingual | `en`, `es`, `de`, `fr`, `pt`, `it` | Per turn             |
| Universal-Streaming English      | `en` only                          | No                   |

See [Select the speech model](/streaming/select-the-speech-model) for a full model comparison.

## Looking for pre-recorded code switching?

This guide covers code switching for **streaming (real-time audio)**. If you're working with pre-recorded audio, see [Code Switching (Pre-recorded)](/pre-recorded-audio/code-switching).
