Migration guide: AWS Transcribe to AssemblyAI

This guide walks through the process of migrating from AWS Transcribe to AssemblyAI for transcribing pre-recorded audio.

Get Started

Before we begin, make sure you have an AssemblyAI account and an API key. You can sign up for a free account and get your API key from your dashboard.

Side-by-side code comparison

Below is a side-by-side comparison of a basic snippet to transcribe a file by AWS Transcribe and AssemblyAI:

1import time
2import boto3
3
4def transcribe_file(job_name, file_uri, transcribe_client):
5 transcribe_client.start_transcription_job(
6 TranscriptionJobName=job_name,
7 Media={"MediaFileUri": file_uri},
8 MediaFormat="wav",
9 LanguageCode="en-US",
10 )
11
12 max_tries = 60
13 while max_tries > 0:
14 max_tries -= 1
15
16 job = transcribe_client.get_transcription_job(
17 TranscriptionJobName=job_name
18 )
19
20 job_status = job["TranscriptionJob"]["TranscriptionJobStatus"]
21
22 if job_status in ["COMPLETED", "FAILED"]:
23 print(f"Job {job_name} is {job_status}.")
24
25 if job_status == "COMPLETED":
26 print(
27 f"Download the transcript from\n"
28 f"\t{job['TranscriptionJob']['Transcript']['TranscriptFileUri']}."
29 )
30 break
31 else:
32 print(f"Waiting for {job_name}. Current status is {job_status}.")
33 time.sleep(10)
34
35def main():
36 transcribe_client = boto3.client("transcribe")
37 file_uri = "s3://test-transcribe/answer2.wav"
38 transcribe_file("Example-job", file_uri, transcribe_client)
39
40if name == "main":
41 main()

Installation

1import boto3
2import time
3
4transcribe_client = boto3.client("transcribe")

When migrating from AWS to AssemblyAI, you’ll first need to handle authentication and SDK setup:

Get your API key from your AssemblyAI dashboard

Things to know:

  • Store your API key securely in an environment variable
  • API key authentication works the same across all AssemblyAI SDKs

Audio File Sources

1def transcribe_file(job_name, file_uri, transcribe_client):
2 transcribe_client.start_transcription_job(
3 TranscriptionJobName=job_name,
4 Media={"MediaFileUri": file_uri},
5 MediaFormat="wav",
6 LanguageCode="en-US",
7 )

Here are helpful things to know when migrating your audio input handling:

Basic Transcription

1while max_tries > 0:
2 max_tries -= 1
3 job = transcribe_client.get_transcription_job(
4 TranscriptionJobName=job_name
5 )
6 job_status = job["TranscriptionJob"]["TranscriptionJobStatus"]
7 if job_status in ["COMPLETED", "FAILED"]:
8 break
9 time.sleep(10)

Here are helpful things to know about our transcribe method:

  • The SDK handles polling under the hood
  • Transcript is directly accessible via transcript.text
  • English is the default language if none is specified
  • We have a cookbook for error handling common errors when using our API.

Adding Features

1transcribe_client.start_transcription_job(
2 TranscriptionJobName=job_name,
3 Media={"MediaFileUri": file_uri},
4 Settings={
5 "ShowSpeakerLabels": True,
6 "MaxSpeakerLabels": 2
7 }
8)

Key differences:

  • Use aai.TranscriptionConfig to specify any extra features that you wish to use
  • The results for Speaker Diarization are stored in transcript.utterances. To see the full transcript response object, refer to our API Reference.
  • Check our documentation for our full list of available features and their parameters