AssemblyAI-STT-3.7 (Recommended)
AssemblyAI-STT-3.7 natively handles code switching across 32 languages. Setlanguage_detection as True and the model 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.
See AssemblyAI-STT-3.7 code switching in action.
English <> French
Quickstart
Universal-2 (Legacy)
While Universal-2 supports code switching, we recommend upgrading to AssemblyAI-STT-3.7 for best results. To enable code switching on Universal-2, setspeech_models to universal-2, language_detection to true, and code_switching to true inside the language_detection_options parameter.
Quickstart
Configuration
Manually Setting Language Codes On Universal-2, you can use thelanguage_codes parameter to set the languages manually. A maximum of two language codes can be set, and one of them must be "en". For example, if your file contains both English and Spanish, it would be "language_codes": ["en", "es"].
These two-code, English-required limits apply to Universal-2 only. On AssemblyAI-STT-3.7,
language_codes accepts any number of languages and English is not required. See Set language manually.code_switching_confidence_threshold parameter controls how the model routes transcription when multiple languages are detected.
When code switching is enabled, the model detects up to two languages per audio file and assigns each a confidence score.
Code Switching Routing BehaviorThis parameter controls routing, not rejection. Audio is always transcribed, even if confidence scores do not meet this threshold. To return an error instead of a low-confidence transcription, you can use language_confidence_threshold alongside this parameter.
- If the non-English language’s confidence score meets or exceeds the threshold, the audio is routed to that non-English language model.
- If the non-English language’s confidence score falls below the threshold, the audio is routed to whichever language has the highest overall confidence, which may be English or non-English.
- If both detected languages are non-English, the audio is always routed to whichever has the higher confidence score, regardless of the threshold.
Code Switching DefaultBy default, the
code_switching_confidence_threshold parameter is set to 0.3. If you would like to disable this, make sure to set this parameter to 0.
Setting code_switching_confidence_threshold to 0 means the non-English language is always used for routing, even with very low confidence.Support for 99 languages
AssemblyAI-STT-3.7 supports 32 languages. To cover the rest of the 99 languages Universal-2 supports, setspeech_models to ["assemblyai-stt-3-7", "universal-2"] when you use language_detection. If you set a language_code that AssemblyAI-STT-3.7 doesn’t support, AssemblyAI falls back to Universal-2 automatically. See Transcribe all 99 languages by combining speech models.