Skip to main content
Supported Languages, Regions, and ModelsSpeech threshold is supported for all languages, regions, and models.
To only transcribe files that contain at least a specified percentage of spoken audio, you can set the speech_threshold parameter. You can pass any value between 0 and 1. If the percentage of speech in the audio file is below the provided threshold, the value of text is None and the response contains an error message:
Audio speech threshold 0.9461 is below the requested speech threshold value 1.0
A file must contain at least 30 seconds of audio for the amount of spoken audio to reliably be determined.
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_detection=True,
    speech_threshold=0.5
)

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

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

print(transcript.text)