Transcribe a pre-recorded audio file
Learn how to transcribe and analyze an audio file.
Overview
By the end of this tutorial, you’ll be able to:
- Transcribe a pre-recorded audio file.
- Select the speech model for your request.
Here’s the full sample code for what you’ll build in this tutorial:
Python SDK
Python
TypeScript SDK
TypeScript
Before you begin
To complete this tutorial, you need:
- TypeScript or Python installed.
-
A free AssemblyAI account.
Step 1: Install the necessary libraries
Python SDK
Python
TypeScript SDK
TypeScript
Step 2: Configure your request
Python SDK
Python
TypeScript SDK
TypeScript
In this step, you ‘ll create an SDK client and configure it to use your API key.
Browse to API Keys in your dashboard, and then copy your API key.
Create a new Transcriber
and configure it to use your API key. Replace YOUR_API_KEY
with your copied API key.
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.
Creating self hosted audio URLs
You can use a service like Amazon S3, Google Cloud Storage, or any platform that supports direct file access to generate a shareable audio file URL. Check out this cookbook on how to transcribe from an S3 bucket.
Local audio files
If you want to use a local file, you can also specify a local path, for example:
YouTube
YouTube URLs are not supported. If you want to transcribe a YouTube video, you need to download the audio first.
Select the speech model: Create a TranscriptionConfig object and set the speech_model
to aai.SpeechModel.slam_1
.
Selecting the right speech model for your use-case
This example shows our latest prompt-based speech model, Slam-1. You can select the class of models to use in order to make cost-performance tradeoffs best suited for your application. See Models for more information about our available models.
Step 3: Submit for transcription
Python SDK
Python
TypeScript SDK
TypeScript
Next steps
In this tutorial, you’ve learned how to generate a transcript for an audio file and how to set the speech 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. Contact our support team at support@assemblyai.com or create a support ticket.