Skip to content

Commit 2fa2ebd

Browse files
authored
Merge pull request #2713 from archiev4/archiev4-feature-apigw-lambda-transcribe
New serverless pattern - apigw-lambda-transcribe
2 parents c46e7d0 + 4a586a0 commit 2fa2ebd

File tree

7 files changed

+468
-0
lines changed

7 files changed

+468
-0
lines changed

apigw-lambda-transcribe/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Subtitle generation with AWS Lambda and Amazon Transcribe
2+
3+
Using this sample pattern, users can securely upload videos to an Amazon S3 bucket by requesting a pre-signed URL through Amazon API Gateway. This URL allows secure and temporary access for uploading files directly to S3.
4+
5+
Once a video file is uploaded, an S3 event invokes another Lambda function to start the Transcribe job using the StartTranscriptionJob API. Once the transcription is completed, the generated subtitles will be stored in the output S3 bucket.
6+
7+
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/apigw-lambda-transcribe
8+
9+
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
10+
11+
## Requirements
12+
13+
* [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
14+
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured
15+
* [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
16+
* [Terraform](https://learn.hashicorp.cxom/tutorials/terraform/install-cli?in=terraform/aws-get-started) installed
17+
18+
## Deployment Instructions
19+
20+
1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
21+
```
22+
git clone https://github.com/aws-samples/serverless-patterns
23+
```
24+
1. Change directory to the pattern directory:
25+
```
26+
cd apigw-lambda-transcribe
27+
```
28+
1. From the command line, initialize terraform to downloads and installs the providers defined in the configuration:
29+
```
30+
terraform init
31+
```
32+
1. From the command line, apply the configuration in the main.tf file:
33+
```
34+
terraform apply
35+
```
36+
1. During the prompts
37+
```
38+
#var.prefix
39+
- Enter a value: {enter any prefix to associate with resources}
40+
41+
#var.region
42+
- Enter a value: {enter the region for deployment}
43+
```
44+
45+
## Testing
46+
47+
1. Make a POST request to the API using the following cURL command:
48+
49+
```
50+
curl --location 'API_ENDPOINT' --header 'Content-Type: application/json' --data '{"object_name": "video.mp4", "content_type": "video/mp4"}'
51+
```
52+
53+
Note: Replace `API_ENDPOINT` with the generated `api_endpoint` from Terraform (refer to the Terraform Outputs section) `object_name` with your desired name for the S3 object and `content_type` with the content type of the video, for ex, mp4.
54+
55+
1. Get the pre-signed URL from the previous step and use the following cURL command to upload the object in S3:
56+
57+
```
58+
curl -v --location -T "video.mp4" 'PRESIGNED_URL' --header 'Content-Type: video/mp4'
59+
```
60+
61+
Note: Replace `PRESIGNED_URL` with pre-signed URL generated in the previous step. `Content-Type` should match the content type used to generate the pre-signed URL in the previous step.
62+
63+
Once this command is run successfully and the object is uploaded, HTTP 200 OK should be seen. You can also check the S3 bucket to see if the object is uploaded correctly.
64+
65+
1. Once the object is uploaded successfully, the `process_s3_event` Lambda function is invoked. Lambda function will then invoke the `StartTranscriptionJob` API and Amazon Transcribe will upload the transcribed output to the output S3 bucket (Refer to the Terraform Outputs section under `output_bucket_name`).
66+
67+
## Cleanup
68+
69+
1. Delete the Transcription jobs:
70+
Go to Transcribe > Transcription jobs > Select your transcription jobs and choose Delete
71+
72+
1. Change directory to the pattern directory:
73+
```
74+
cd serverless-patterns/apigw-lambda-transcribe
75+
```
76+
77+
1. Delete all created resources
78+
```
79+
terraform destroy
80+
```
81+
82+
1. During the prompts:
83+
```
84+
Enter all details as entered during creation.
85+
```
86+
87+
1. Confirm all created resources has been deleted
88+
```
89+
terraform show
90+
```
91+
----
92+
Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
93+
94+
SPDX-License-Identifier: MIT-0
20.5 KB
Loading
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"title": "Subtitle generation using AWS API Gateway and AWS Lambda",
3+
"description": "This pattern creates an AWS Lambda function which will invoke Amazon Transcribe for speech-to-text conversion, and stores results in Amazon S3",
4+
"language": "Python",
5+
"level": "200",
6+
"framework": "Terraform",
7+
"introBox": {
8+
"headline": "How it works",
9+
"text": [
10+
"This sample pattern is an automated serverless solution for subtitle generation using AWS services. This system securely handles video file uploads via pre-signed URLs, automatically triggers Amazon Transcribe for speech-to-text conversion, and stores results in S3."
11+
]
12+
},
13+
"gitHub": {
14+
"template": {
15+
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-lambda-transcribe",
16+
"templateURL": "serverless-patterns/apigw-lambda-transcribe",
17+
"projectFolder": "apigw-lambda-transcribe",
18+
"templateFile": "main.tf"
19+
}
20+
},
21+
"resources": {
22+
"bullets": [
23+
{
24+
"text": "Uploading objects with presigned URLs",
25+
"link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html"
26+
},
27+
{
28+
"text": "StartTranscriptionJob",
29+
"link": "https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html"
30+
}
31+
]
32+
},
33+
"deploy": {
34+
"text": ["terraform init", "terraform apply"]
35+
},
36+
"testing": {
37+
"text": ["See the GitHub repo for detailed testing instructions."]
38+
},
39+
"cleanup": {
40+
"text": ["terraform destroy", "terraform show"]
41+
},
42+
"authors": [
43+
{
44+
"name": "Archana V",
45+
"image": "https://media.licdn.com/dms/image/v2/D5603AQGhkVtEhllFEw/profile-displayphoto-shrink_400_400/B56ZZH3LL6H0Ag-/0/1744962369913?e=1750291200&v=beta&t=R0hX6jzWC03OyoWKvYJ0jDDTuPocobPSy0lAJY-3XfA",
46+
"bio": "Solutions Architect at AWS",
47+
"linkedin": "archana-venkat-9b80b7184"
48+
}
49+
],
50+
"patternArch": {
51+
"icon1": {
52+
"x": 15,
53+
"y": 50,
54+
"service": "s3",
55+
"label": "Amazon S3"
56+
},
57+
"icon2": {
58+
"x": 40,
59+
"y": 50,
60+
"service": "lambda",
61+
"label": "AWS Lambda"
62+
},
63+
"icon3": {
64+
"x": 65,
65+
"y": 50,
66+
"service": "transcribe",
67+
"label": "Amazon Transcribe"
68+
},
69+
"icon4": {
70+
"x": 90,
71+
"y": 50,
72+
"service": "s3",
73+
"label": "Amazon S3"
74+
},
75+
"line1": {
76+
"from": "icon1",
77+
"to": "icon2",
78+
"label": ""
79+
},
80+
"line2": {
81+
"from": "icon2",
82+
"to": "icon3",
83+
"label": ""
84+
},
85+
"line3": {
86+
"from": "icon3",
87+
"to": "icon4",
88+
"label": ""
89+
}
90+
}
91+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"title": "Subtitle generation using AWS API Gateway and AWS Lambda",
3+
"description": "This pattern creates an AWS Lambda function which will invoke Amazon Transcribe for speech-to-text conversion, and stores results in Amazon S3",
4+
"language": "Python",
5+
"level": "200",
6+
"framework": "Terraform",
7+
"introBox": {
8+
"headline": "How it works",
9+
"text": [
10+
"This sample pattern is an automated serverless solution for subtitle generation using AWS services. This system securely handles video file uploads via pre-signed URLs, automatically triggers Amazon Transcribe for speech-to-text conversion, and stores results in S3."
11+
]
12+
},
13+
"gitHub": {
14+
"template": {
15+
"repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/apigw-lambda-transcribe",
16+
"templateURL": "serverless-patterns/apigw-lambda-transcribe",
17+
"projectFolder": "apigw-lambda-transcribe",
18+
"templateFile": "main.tf"
19+
}
20+
},
21+
"resources": {
22+
"bullets": [
23+
{
24+
"text": "Uploading objects with presigned URLs",
25+
"link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/PresignedUrlUploadObject.html"
26+
},
27+
{
28+
"text": "StartTranscriptionJob",
29+
"link": "https://docs.aws.amazon.com/transcribe/latest/APIReference/API_StartTranscriptionJob.html"
30+
}
31+
]
32+
},
33+
"deploy": {
34+
"text": [
35+
"terraform init",
36+
"terraform apply"
37+
]
38+
},
39+
"testing": {
40+
"text": [
41+
"See the GitHub repo for detailed testing instructions."
42+
]
43+
},
44+
"cleanup": {
45+
"text": [
46+
"terraform destroy",
47+
"terraform show"
48+
]
49+
},
50+
"authors": [
51+
{
52+
"name": "Archana V",
53+
"image": "https://media.licdn.com/dms/image/v2/D5603AQGhkVtEhllFEw/profile-displayphoto-shrink_400_400/B56ZZH3LL6H0Ag-/0/1744962369913?e=1750291200&v=beta&t=R0hX6jzWC03OyoWKvYJ0jDDTuPocobPSy0lAJY-3XfA",
54+
"bio": "Solutions Architect at AWS",
55+
"linkedin": "archana-venkat-9b80b7184"
56+
}
57+
]
58+
}
806 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)