Set Language Manually

Universaluniversal

US & EU

If you already know the dominant language of your audio file, you can use the language_code parameter to specify the language rather than using Automatic language detection.

When you specify a language, the system automatically routes your request to the best available model based on that language and the models you provide in the speech_models parameter. For example, with speech_models: ["universal-3-pro", "universal-2"], the system will use Universal-3-Pro for languages it supports and automatically fall back to Universal-2 for all other languages. You can check which model processed your request using the speech_model_used field in the response. See the Model selection page for more details.

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5# audio_file = "./local_file.mp3"
6audio_file = "https://assembly.ai/wildfires.mp3"
7
8config = aai.TranscriptionConfig(
9 speech_models=["universal-3-pro", "universal-2"],
10 language_code="es"
11)
12
13transcript = aai.Transcriber(config=config).transcribe(audio_file)
14
15if transcript.status == "error":
16 raise RuntimeError(f"Transcription failed: {transcript.error}")
17
18print(transcript.text)

See the Supported Languages & Features page for all supported languages and their codes.