For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
PlaygroundChangelogSign In
OverviewAPI ReferencePre-recorded STTStreaming STTVoice AgentsSpeech UnderstandingGuardrailsLLM GatewayFAQ
OverviewAPI ReferencePre-recorded STTStreaming STTVoice AgentsSpeech UnderstandingGuardrailsLLM GatewayFAQ
  • Models & features
    • Getting started
    • Redact PII from transcripts
    • Detect sensitive content
    • Filter profanity from transcripts
    • Set minimum speech threshold
LogoLogo
PlaygroundChangelogSign In
Models & features

Speech Threshold

Was this page helpful?
Previous
Built with
Supported Languages, Regions, and Models

Speech 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:

1Audio 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.

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_detection=True,
11 speech_threshold=0.5
12)
13
14transcript = aai.Transcriber(config=config).transcribe(audio_file)
15
16if transcript.status == "error":
17 raise RuntimeError(f"Transcription failed: {transcript.error}")
18
19print(transcript.text)