Pre-Recorded Audio

Our Speech-to-Text model enables you to transcribe pre-recorded audio into written text.

On top of the transcription, you can enable other features and models, such as Speaker Diarization, by adding additional parameters to the same transcription request.

Choose Model Class

You can use the optional speech_model parameter to specify the class of models. To learn more, see Select the speech model.

Quickstart

The following example transcribes an audio file from a local file.

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5audio_file = "./local_file.mp3"
6# audio_file = "https://assembly.ai/wildfires.mp3"
7
8config = aai.TranscriptionConfig(speech_model=aai.SpeechModel.slam_1)
9
10transcript = aai.Transcriber(config=config).transcribe(audio_file)
11
12if transcript.status == "error":
13 raise RuntimeError(f"Transcription failed: {transcript.error}")
14
15print(transcript.text)

Example output

1Smoke from hundreds of wildfires in Canada is triggering air quality alerts
2throughout the US. Skylines from Maine to Maryland to Minnesota are gray and
3smoggy. And...

API reference

You can find the API reference here.