Multilingual Codeswitching
Transcribe conversations where speakers switch between multiple languages.
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 only available when using the Nova-2 model.
1. Enable Feature
To enable Multilingual Codeswitching, use the following language parameter in the query string when you call Deepgram’s /listen
endpoint :
language=multi
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
.
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.
- 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: