🏠 Home | ← Back | Next →

Github Repo: https://github.com/pedropcamellon/medical-calls-analysis-aws

Introduction

In the previous article, we used Amazon Transcribe to obtain transcribed JSON files from audio recordings. Now, we'll summarize these files using the Titan model, an LLM hosted on Amazon Bedrock. This process shows how to transform lengthy conversations into concise, actionable summaries. Amazon Bedrock provides secure access to leading AI foundation models through a single API. Though we're focusing on medical applications, this approach works for any industry involving communication and information exchange—providing an efficient way to streamline information processing.

We'll combine AWS Lambda for serverless computing with Amazon Bedrock's language models to create an efficient solution that can process and analyze conversations at scale. The system uses S3 triggers to automatically initiate processing when new audio files are uploaded, demonstrating how to create a fully automated workflow for handling communication data. We'll cover everything from initial setup to implementation details.

Create an Amazon S3 Bucket

We first need to create a storage bucket. Begin by logging into the AWS Management Console and navigate to the S3 service, either by searching for "S3" in the service search bar or selecting it from the "Storage" section. Once there, click on the "Create bucket" button. This will prompt you to provide details for the new bucket. Start by entering a unique name for your bucket in the "Bucket name" field and then select the Region in which you want your bucket to be located. The other settings can be left at their default values for now. After that, scroll down and click on the "Create bucket" button. Now your bucket is ready for use, and you can proceed to upload your files.

Amazon Transcribe Permissions

To allow automatic transcription when new audio files are uploaded to our S3 bucket, we need to create an IAM role that gives Amazon Transcribe access to our audio files. This role requires the following permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::medical-calls-audio-bucket/*"
            ]
        }
    ]
}

Summarize Lambda Function Code

Now that we have our audio files and transcripts in S3, let's create a Lambda function to summarize the transcribed content using Amazon Bedrock. This function will process the JSON transcripts and generate concise summaries using a Large Language Model.

Here's how the summarization workflow operates:

  1. A new transcript JSON file appears in the S3 'transcripts' folder
  2. This triggers our summarization Lambda function
  3. The function retrieves and processes the transcript
  4. It sends the processed text to Amazon Bedrock
  5. Bedrock analyzes the content and generates a summary
  6. The summary is saved back to S3 in a 'summaries' folder

This automated approach ensures efficient processing of our transcripts. The Lambda function handles the entire workflow: reading the JSON transcript, formatting the content for the LLM, making the API call to Bedrock, and storing the results. The function includes error handling and logging to track any issues that may arise during processing.