Harnessing the Power of AWS Services: Transcribing MP3 Files with Lambda and Transcribe

Nithish Kumar
3 min readJul 4, 2023

--

Introduction:

In this blog, we’ll explore how to leverage the power of various AWS services to transcribe MP3 files automatically. We’ll utilize Amazon S3, AWS Lambda, and Amazon Transcribe to create a seamless workflow for transcribing audio content. By the end of this guide, you’ll have a fully functional system that can transcribe your MP3 files with ease.

Step 1: Create an S3 bucket to store your MP3 files and the transcribed output.

Step 2: Create lambda function which has the code to send mp3 to transcribe job and then output will be stored in same bucket. And python code is here

import json
import boto3
import uuid

myid = uuid.uuid1().int
transcribe = boto3.client(‘transcribe’)
def lambda_handler(event, context):

obj = event[‘Records’][0][‘s3’][‘object’][‘key’]
bucket = event[‘Records’][0][‘s3’][‘bucket’][‘name’]
url = “s3://” + bucket + “/” + obj

resp = transcribe.start_transcription_job(
TranscriptionJobName=’job’+ ‘-’ + str(myid),
LanguageCode=’en-US’,
MediaFormat=’mp3',
OutputBucketName=bucket,
Media={
‘MediaFileUri’: url
},
OutputKey=’job-’ + str(myid) + ‘.json’
)

print(resp)

we have to generate a unique job id every time for running transcribe job. In python, we have a module called uuid to generate a token/id.

Step 3: Create event-notification and give permission/role to lambda to access transcribe service. Go to properties of bucket > event notifications.

Now go to your lambda function and give permission role to access transcribe service.

Step 4: Now upload mp3 file to s3 bucket, in same bucket you will get output file.

Conclusion: By combining the power of Amazon S3, AWS Lambda, and Amazon Transcribe, we’ve created an automated system for transcribing MP3 files. This solution can be easily scaled to handle large volumes of audio content, making it ideal for various applications such as transcription services, voice assistants, and content analysis.

Keep innovating and exploring new ways to leverage AWS services to solve real-world challenges!

…Signing Off…

--

--

Nithish Kumar
Nithish Kumar

Written by Nithish Kumar

Aspiring DevOps/Cloud Engineer. #Believe in you.

No responses yet