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.

Universal-2 offers accurate, cost-effective transcription across 99 languages with low latency. It supports code switching and optional keyterms prompting for domain-specific vocabulary (up to 200 words).

Key capabilities

  • 99 language support: Transcribe audio in 99 languages with high accuracy
  • Keyterms prompting: Improve recognition of up to 200 domain-specific terms, rare words, and proper nouns
  • Code switching: Handle audio that switches between languages

Supported languages


Quickstart

Get started with Universal-2 using the code below. This example transcribes a pre-recorded audio file using the Universal-2 model and prints the transcript text to your terminal.
1
Install the required library
pip install requests
2
Create a new file main.py and paste the code below. Replace <YOUR_API_KEY> with your API key.
3
Run with python main.py.
import requests
import time

base_url = "https://api.assemblyai.com"
headers = {"authorization": "<YOUR_API_KEY>"}

data = {
    "audio_url": "https://assembly.ai/wildfires.mp3",
    "speech_models": ["universal-2"],
    "language_detection": True
}

response = requests.post(base_url + "/v2/transcript", headers=headers, json=data)

if response.status_code != 200:
    print(f"Error: {response.status_code}, Response: {response.text}")
    response.raise_for_status()

transcript_response = response.json()
transcript_id = transcript_response["id"]
polling_endpoint = f"{base_url}/v2/transcript/{transcript_id}"

while True:
    transcript = requests.get(polling_endpoint, headers=headers).json()
    if transcript["status"] == "completed":
        print(transcript["text"])
        break
    elif transcript["status"] == "error":
        raise RuntimeError(f"Transcription failed: {transcript['error']}")
    else:
        time.sleep(3)