Transcribe an audio file
Learn how to transcribe and analyze an audio file.
Dive into our research paper to see how we're redefining speech AI accuracy. Read more here.
Overview
By the end of this tutorial, you'll be able to:
- Transcribe an audio file.
- Enable Speaker Diarization to detect speakers in an audio file.
Here's the full sample code for what you'll build in this tutorial:
Step 1: Install the SDK
Install the package via pip:
Step 2: Configure the SDK
In this step, you 'll create an SDK client and configure it to use your API key.
- 1
Browse to , and then click the text under Your API key to copy it.
- 2
Create a new client using your API key. Replace
YOUR_API_KEY
with your copied API key.
Step 3: Submit audio for transcription
In this step, you'll submit the audio file for transcription and wait until it's completes. The time it takes to process an audio file depends on its duration and the enabled models. Most transcriptions complete within 45 seconds.
- 1
Specify a URL to the audio you want to transcribe. The URL needs to be accessible from AssemblyAI's servers. For a list of supported formats, see FAQ.
YouTubeYouTube URLs are not supported. If you want to transcribe a YouTube video, you need to download the audio first.
- 2
To generate the transcript, pass the audio URL to
transcribe()
.This may take a minute while we're processing the audio.
Select the speech modelYou can select the class of models to use in order to make cost-performance tradeoffs best suited for your application. See Select the speech model.
- 3
If the transcription failed, the
status
of the transcription will be set toerror
. To see why it failed you can print the value oferror
. - 4
Print the complete transcript.
- 5
Run the application and wait for it to finish.
You've successfully transcribed your first audio file. You can see all submitted transcription jobs in the .
Step 4: Enable additional AI models
You can extract even more insights from the audio by enabling any of our AI models using transcription options. In this step, you'll enable the Speaker diarization model to detect who said what.
- 1
Create a
TranscriptionConfig
withspeaker_labels
set toTrue
, and then pass it as the second argument totranscribe()
. - 2
In addition to the full transcript, you now have access to utterances from each speaker.
Many of the properties in the transcript object only become available after you enable the corresponding model. For more information, see the models under Speech-to-Text and Audio Intelligence.
Next steps
In this tutorial, you've learned how to generate a transcript for an audio file and how to extract speaker information by enabling the Speaker diarization model.
Want to learn more?
- For more ways to analyze your audio data, explore our Audio Intelligence models.
- If you want to transcribe audio in real-time, see Transcribe streaming audio from a microphone.
- To search, summarize, and ask questions on your transcripts with LLMs, see LeMUR.
Need some help?
If you get stuck, or have any other questions, we'd love to help you out. Ask our support team in our Discord server.