Multilingual Codeswitching
language string Option: multi
The Multilingual Codeswitching feature in Deepgram’s API allows you to transcribe conversations where speakers switch between multiple languages. This guide will walk you through enabling this feature, how to use it with cURL, and how to analyze and interpret the response.
Multilingual Code Switching is available on Nova-2, Nova-3, Nova-3 Medical (nova-3-medical), and Flux Multilingual (flux-general-multi). Nova-3 multilingual supports 55 languages. See the list of supported languages for each multilingual model.
1. Enable Feature
Nova-2 / Nova-3
To enable Multilingual Codeswitching on Nova-2 or Nova-3, use the following language parameter in the query string when you call Deepgram’s /listen endpoint:
language=multi
The same language=multi parameter works with model=nova-3-medical for multilingual transcription of medical audio.
Pre-Recorded Audio
To transcribe audio from a file on your computer that contains multiple languages, run the following cURL command in a terminal or your favorite API client.
Replace YOUR_DEEPGRAM_API_KEY with your Deepgram API Key.
Streaming Audio
To transcribe an audio stream, initiate a websocket connection, including the parameter language=multi. For instance:
We recommend using an endpointing value of 100 ms for code-switching, endpointing=100.
Nova-3 Language Hints
With Nova-3 (model=nova-3&language=multi), you can add one or more optional language_hint parameters to bias detection toward the languages you expect. Hints bias detection but do not restrict it, and the model still transcribes other supported languages it hears. Repeat the parameter to pass several hints.
Pre-recorded:
Streaming:
language_hint only applies with language=multi and is ignored otherwise. Nova-2 does not support language_hint. A hint that is not a supported code fails the request with HTTP 400 (INVALID_QUERY_PARAMETER). See the Nova-3 Language Prompting guide for usage scenarios and response details.
Flux Multilingual
Flux Multilingual handles code-switching natively. Instead of language=multi, use model=flux-general-multi with optional language_hint parameters to bias toward expected languages.
Flux returns detected languages in every TurnInfo event via the languages field. See the Language Prompting guide for full details on usage scenarios and response format.
3. Analyze Response
Pre-Recorded Audio
When the file is finished processing, you’ll receive a JSON response that has the following basic structure:
In this response, we see that each channel contains:
-
alternatives object, which contains:
- transcript: Transcript for the audio being processed.
- confidence: Floating point value between 0 and 1 that indicates overall transcript reliability. Larger values indicate higher confidence.
- languages: Array of BCP-47 language tags for all detected languages in the channel, sorted in descending order of number of words per language.
- languages_hinted: Array of the
language_hintvalues for the request, normalized (ES→es; a regional code the model has no tag for becomes its base language,en-GB→en). Present on every Nova-3 multilingual response; an empty array when no hint was sent. - words: Object containing each word in the transcript, along with its start time and end time (in seconds) from the beginning of the audio, a word-level transcription confidence value, the language of the word, and the punctuated word if Smart Formatting is enabled.
Streaming Audio
When streaming audio, a Results JSON message has the following structure:
In this message, channel.alternatives contains:
- transcript: Transcript for the audio segment.
- confidence: Floating point value between 0 and 1 that indicates overall transcript reliability.
- languages: Array of BCP-47 language tags for the languages detected in the segment, sorted in descending order of number of words per language.
- languages_hinted: Array of the
language_hintvalues set when the connection opened, normalized (ES→es; a regional code the model has no tag for becomes its base language,en-GB→en). Present on every interim and final result of a Nova-3 multilingual stream; an empty array when no hint was sent. - words: Each word in the segment with its start and end time, confidence, and detected
language.