Skip to main content

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.


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.
If you set language_code and enable a feature that isn’t supported for that language, the API will reject the request with an error such as "The following models are not available in this language: speaker_labels". Check the Supported Languages & Features page to verify which features are available for your language before submitting a request.
import assemblyai as aai

aai.settings.api_key = "<YOUR_API_KEY>"

# audio_file = "./local_file.mp3"
audio_file = "https://assembly.ai/wildfires.mp3"

config = aai.TranscriptionConfig(
    speech_models=["universal-3-pro", "universal-2"],
    language_code="es"
)

transcript = aai.Transcriber(config=config).transcribe(audio_file)

if transcript.status == "error":
  raise RuntimeError(f"Transcription failed: {transcript.error}")

print(transcript.text)
See the Supported Languages & Features page for all supported languages and their codes.