Quickstart: transcribe an audio file
This tutorial will show you how to transcribe audio from a file. To transcribe prerecorded audio from other sources, see File transcription. To transcribe streaming audio in real time, see the realtime quickstart.
Get an API key
Get an API key
First, you'll need a Mistral API key. If you don't have one, then go to Studio. Navigate to the API keys section and create a new API key.
Store your API key in the MISTRAL_API_KEY environment variable:
export MISTRAL_API_KEY="your-api-key"Install the SDK
Install the SDK
To use Python or TypeScript, install the Mistral SDK. The curl example needs no install.
pip install mistralaiTranscribe your audio
Transcribe your audio
To follow along without a file of your own, download the sample recording:
curl -O https://docs.mistral.ai/audio/obama.mp3Use this code to transcribe speech from an audio file to text. The speech can be in multiple languages.
import os
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
with open("obama.mp3", "rb") as audio:
transcription = client.audio.transcriptions.complete(
model="voxtral-mini-transcribe-3",
file={"file_name": "obama.mp3", "content": audio},
)
print(transcription.text)You should see
You should see
I'm recording some speech now for testing. Et on peut aussi parler français !Going further