Skip to content

Commit 57802ed

Browse files
author
Arun Thangavel
committed
Added CDK and Lambda Functions
1 parent 600882e commit 57802ed

File tree

6 files changed

+93
-6
lines changed

6 files changed

+93
-6
lines changed

AWSCloudformation_Resources.png

55.8 KB
Loading

Infra/src/main/java/com/myorg/S3LambdaTranscribeJavaCdkStack.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public S3LambdaTranscribeJavaCdkStack(final Construct scope, final String id, fi
3535
// .description("Name of the destination bucket")
3636
// .build();
3737

38-
CfnParameter languageCode = CfnParameter.Builder.create(this, "TranscribeLanguageCode")
38+
CfnParameter languageCode = CfnParameter.Builder.create(this, "transcribeLanguageCode")
3939
.type("String")
4040
.description("Language code for the transcription")
4141
.defaultValue("es-US,en-US")
@@ -76,6 +76,7 @@ public S3LambdaTranscribeJavaCdkStack(final Construct scope, final String id, fi
7676

7777
// Attach the necessary policies to the Lambda role
7878
lambdaRole.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName("AmazonTranscribeFullAccess"));
79+
lambdaRole.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName("CloudWatchLogsFullAccess"));
7980

8081

8182
Function audioTranscribeFunction = Function.Builder.create(this, "AudioTranscribe")
@@ -88,6 +89,7 @@ public S3LambdaTranscribeJavaCdkStack(final Construct scope, final String id, fi
8889
.environment(Map.of("LANGUAGE_CODE", languageCode.getValueAsString(),
8990
"OUTPUT_BUCKET", destinationBucket.getBucketName()))
9091
.role(lambdaRole)
92+
9193
.build();
9294

9395

README.md

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,105 @@
11
# Audio to Text using Amazon Transcribe
22

3+
Java AWS CDK application to convert audio files to text using Amazon Transcribe.
4+
35
## Architecture
46

5-
![architecture.png](architecture.png)
7+
![s3-lambda-transcribe-java-cdk.drawio.png](s3-lambda-transcribe-java-cdk.png)
68

79
## Description
810

911
Serverless application that converts audio files to text using Amazon Transcribe.
1012

11-
Follow the below steps to deploy the application.
13+
Source Bucket - S3 bucket where audio files are uploaded.
14+
Lambda Function - Lambda function that is triggered when an audio file is uploaded to the source bucket. The function converts the audio file to text using Amazon Transcribe and stores the result in the destination bucket.
15+
Transcribe - Amazon Transcribe job that converts the audio file to text.
16+
Destination Bucket - S3 bucket where the text file is stored.
17+
18+
19+
## Pre-requisites
20+
21+
* AWS Account
22+
* Java 11 or later
23+
```
24+
java -version
25+
```
26+
* Maven 3.0 or later
27+
```
28+
mvn -version
29+
```
30+
* AWS CLI
31+
```
32+
aws --version
33+
```
34+
35+
* Node.js 18.x or later
36+
```
37+
node -v
38+
```
1239

40+
* AWS CDK - Install the [AWS CDK Toolkit](https://docs.aws.amazon.com/cdk/v2/guide/cli.html) globally using the following command:
41+
```
42+
npm install -g aws-cdk
43+
```
44+
```
45+
cdk --version
46+
```
47+
* CDK Bootstrap - Bootstrap your AWS account for CDK. This only needs to be done once per account/region.
48+
```
49+
cdk bootstrap aws://<account>/<region>
50+
```
1351

1452
## Installation
1553

54+
Clone the repository and navigate to the project directory.
55+
```
56+
git clone https://github.com/arunt4ever/s3-lambda-transcribe-java-cdk.git
57+
cd s3-lambda-transcribe-java-cdk
58+
```
59+
60+
## Build
61+
Run below build command from the root directory of the project.
62+
```
63+
mvn clean install
64+
```
65+
66+
## Deployment
67+
68+
Change to the Infra directory of the project.
69+
```
70+
cd Infra
71+
```
72+
73+
Quick deployment: This will deploy the application with default options that support 2 langauge conversion "en-US" and "es-US".<br>
74+
Run the below command to deploy the application.
75+
```
76+
cdk deploy
77+
```
78+
79+
Custom deployment: This will deploy the application with custom options that support 3 langauge conversion "en-US","es-US" and "es-ES".<br>
80+
81+
Please refer to this [link](https://docs.aws.amazon.com/transcribe/latest/dg/supported-languages.html) for more Amazon Transcribe supported languages and use the language code as shown below.
1682

83+
Run the below command to deploy the application.
84+
```
85+
cdk deploy --no-previous-parameters --parameters transcribeLanguageCode=en-US,es-US,es-ES
86+
```
87+
88+
## Verify
89+
90+
[AWS CloudFormation](https://us-west-2.console.aws.amazon.com/cloudformation/home) will create the below resources.
91+
![AWSCloudformation_Resources.png](AWSCloudformation_Resources.png)
92+
93+
Source Bucket and Destination Bucket will be created with unique names.
94+
95+
## Testing
96+
97+
Upload an audio file to the source bucket. The file will be converted to text and stored in the destination bucket.
98+
99+
100+
## Cleanup
101+
102+
Run the below command to delete the application.
103+
```
104+
cdk destroy
17105
```
18-
git clone [repository_url]
19-
cd [project_directory]
20-
[installation_commands]

architecture.png

-25.9 KB
Binary file not shown.

assets/AudioTranscribeFunction.jar

376 Bytes
Binary file not shown.

s3-lambda-transcribe-java-cdk.png

33.2 KB
Loading

0 commit comments

Comments
 (0)