Migration guide: AWS Transcribe to AssemblyAI

This guide walks through the process of migrating from AWS Transcribe to AssemblyAI.

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

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
Check our documentation for the full list of available SDKs

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